oscarefonseca (3) [Avatar] Offline
#1
Hello Mark,
Thank you for all the information you share in your book!

I am starting with Dependency Injection in WPF using the MVVM. I nee an Open File Dialog and a Save File Dialog and I am not quite sure how to do it without writing my own Dialog but at the same time keeping the MVVM.

What would you do in this case?

Best regards,

Oscar.
mark.seemann (383) [Avatar] Offline
#2
Re: Open File Dialog
Hello Oscar

Thank you for writing.

Let's start with the essential questions: what is the purpose of showing the Open File Dialog and Save File Dialog?

Is the purpose to collect a file path, or is the purpose to show UI?
oscarefonseca (3) [Avatar] Offline
#3
Re: Open File Dialog
Hello Mark,
The purpose is just to get the path for an existing file in case of Open or the location where a new file should be saved. So it is just the standard functionality.
mark.seemann (383) [Avatar] Offline
#4
Re: Open File Dialog
OK. So is that really a part of your MVVM architecture? Or are they just two services that provide a file path when you invoke them?
oscarefonseca (3) [Avatar] Offline
#5
Re: Open File Dialog
I see.
That's a good point. Actually I can treat them as services independent of MVVM.
Thank you!
mark.seemann (383) [Avatar] Offline
#6
Re: Open File Dialog
Yes, exactly!

Hide these services behind an interface. It's only an implementation detail that concrete implementations pop up some UI smilie