wpf - Open File Dialog MVVM -


Ok I really want to know how expert MVVM developers handle an open file in WPF.

I do not really want to do this in my ViewModel (where 'Browse' is referred to through a representative)

  Browse Zero (the Ultimate Object) {/ code here Add OpenFileDialog d = New OpenFileDialog (); If (D. Shodiolog () == true) {// do stuff}}  

Because I believe that the MVVM is against the system.

What do I do?

The best thing to do here is to use a service.

A service is just one category that you use from central stores of services, often an IOC container

assuming that you have IFileDialogService , you can do this ...

  Browse zero (the object is param) {var fileDialogService = container.Resolve & lt; IFileDialogService & gt; (); String path = fileDialogService.OpenFileDialog (); If (! String.IsNullOrEmpty (path)) {// Do stuff}}  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -