Click here to Skip to main content
15,912,897 members
Home / Discussions / WPF
   

WPF

 
QuestionSilverlight App versus Silverlight Busines App Pin
Kevin Marois24-Jan-12 8:09
professionalKevin Marois24-Jan-12 8:09 
AnswerRe: Silverlight App versus Silverlight Busines App Pin
Abhinav S25-Jan-12 0:45
Abhinav S25-Jan-12 0:45 
Questiondynamicaly open elements from a xaml resource Pin
Giorgi Nistor23-Jan-12 22:37
Giorgi Nistor23-Jan-12 22:37 
AnswerRe: dynamicaly open elements from a xaml resource Pin
Giorgi Nistor23-Jan-12 23:50
Giorgi Nistor23-Jan-12 23:50 
GeneralRe: dynamicaly open elements from a xaml resource Pin
Giorgi Nistor25-Jan-12 4:07
Giorgi Nistor25-Jan-12 4:07 
QuestionMVVM architecture Pin
mi_n22-Jan-12 21:18
mi_n22-Jan-12 21:18 
AnswerRe: MVVM architecture Pin
Wayne Gaylard22-Jan-12 21:59
professionalWayne Gaylard22-Jan-12 21:59 
GeneralRe: MVVM architecture Pin
mi_n23-Jan-12 8:51
mi_n23-Jan-12 8:51 
GeneralRe: MVVM architecture Pin
Dean Oliver23-Jan-12 18:35
Dean Oliver23-Jan-12 18:35 
GeneralRe: MVVM architecture Pin
mi_n24-Jan-12 21:03
mi_n24-Jan-12 21:03 
AnswerRe: MVVM architecture Pin
Dean Oliver25-Jan-12 19:35
Dean Oliver25-Jan-12 19:35 
Questionconnectionstring Pin
arkiboys20-Jan-12 1:10
arkiboys20-Jan-12 1:10 
SuggestionRe: connectionstring Pin
Dean Oliver27-Jan-12 22:33
Dean Oliver27-Jan-12 22:33 
GeneralRe: connectionstring Pin
arkiboys28-Jan-12 20:19
arkiboys28-Jan-12 20:19 
QuestionWPF Listbox items Pin
programmervb.netc++19-Jan-12 7:22
programmervb.netc++19-Jan-12 7:22 
AnswerRe: WPF Listbox items Pin
Dean Oliver23-Jan-12 19:02
Dean Oliver23-Jan-12 19:02 
QuestionHow to refer ViewModel from user-control code behind? Pin
sbkk16-Jan-12 11:54
sbkk16-Jan-12 11:54 
AnswerRe: How to refer ViewModel from user-control code behind? Pin
Mycroft Holmes16-Jan-12 13:07
professionalMycroft Holmes16-Jan-12 13:07 
AnswerRe: How to refer ViewModel from user-control code behind? Pin
Pete O'Hanlon16-Jan-12 22:29
mvePete O'Hanlon16-Jan-12 22:29 
GeneralRe: How to refer ViewModel from user-control code behind? Pin
sbkk17-Jan-12 4:59
sbkk17-Jan-12 4:59 
GeneralRe: How to refer ViewModel from user-control code behind? Pin
Pete O'Hanlon17-Jan-12 5:21
mvePete O'Hanlon17-Jan-12 5:21 
The standard way for doing this in an MVVM type application is to have an interface that copes with the OpenFileDialog, and use this.

What I mean by this, is that you have an interface (we'll call it IFileOpenDialog) and that you create a class that implements this interface. Now, this class would simply wrap the call to opening the file dialog, and you would register it with something like a service locator - then your VM retrieves an instance of this class from the service locator using the interface and uses that to open the dialog.

Typically, your command would look something like this:
C#
private void OpenFile(object o)
{
  IFileOpenDialog fileOpen = ServiceLocator.Get<IFileOpenDialog>();
  fileOpen.Filters = "All files (*.*)|*.*|";
  bool? result = fileOpen.ShowDialog();
  if (result.HasValue && result.Value == true)
  {
    myFile = fileOpen.FileName;
  }
}
I've just knocked this up in the CP editor, so I apologise for any syntax errors, but hopefully this should demonstrate what I've been talking about.

Forgive your enemies - it messes with their heads

"Mind bleach! Send me mind bleach!" - Nagy Vilmos


My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility


JokeRe: How to refer ViewModel from user-control code behind? Pin
Tom Delany24-Jan-12 11:25
Tom Delany24-Jan-12 11:25 
GeneralRe: How to refer ViewModel from user-control code behind? Pin
Pete O'Hanlon24-Jan-12 12:22
mvePete O'Hanlon24-Jan-12 12:22 
GeneralRe: How to refer ViewModel from user-control code behind? Pin
sbkk19-Jan-12 5:20
sbkk19-Jan-12 5:20 
GeneralRe: How to refer ViewModel from user-control code behind? Pin
sbkk25-Jan-12 3:44
sbkk25-Jan-12 3:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.