Click here to Skip to main content
15,887,027 members
Home / Discussions / WPF
   

WPF

 
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 
QuestionI wanna retrieve value from the hidden column in datagrid in silverlight 4 Pin
mdrizwan_115-Jan-12 18:35
mdrizwan_115-Jan-12 18:35 
AnswerRe: I wanna retrieve value from the hidden column in datagrid in silverlight 4 Pin
Mycroft Holmes15-Jan-12 20:59
professionalMycroft Holmes15-Jan-12 20:59 
GeneralRe: I wanna retrieve value from the hidden column in datagrid in silverlight 4 Pin
mdrizwan_115-Jan-12 22:03
mdrizwan_115-Jan-12 22:03 
GeneralRe: I wanna retrieve value from the hidden column in datagrid in silverlight 4 Pin
mdrizwan_116-Jan-12 23:28
mdrizwan_116-Jan-12 23:28 
QuestionAdding images to silverlight datagrid Pin
sudheesh kumar s14-Jan-12 0:51
sudheesh kumar s14-Jan-12 0:51 
AnswerRe: Adding images to silverlight datagrid Pin
AbhijeetB14-Jan-12 22:05
AbhijeetB14-Jan-12 22:05 
QuestionSlilverlight with WCF Pin
sudheesh kumar s14-Jan-12 0:36
sudheesh kumar s14-Jan-12 0:36 
AnswerRe: Slilverlight with WCF Pin
Pete O'Hanlon14-Jan-12 0:51
mvePete O'Hanlon14-Jan-12 0:51 
GeneralRe: Slilverlight with WCF Pin
sudheesh kumar s14-Jan-12 1:06
sudheesh kumar s14-Jan-12 1:06 
GeneralRe: Slilverlight with WCF Pin
Pete O'Hanlon14-Jan-12 2:18
mvePete O'Hanlon14-Jan-12 2:18 
QuestionSilverlight 5 DataGrid MouseLeftButtonDown Fails Pin
Mycroft Holmes13-Jan-12 21:06
professionalMycroft Holmes13-Jan-12 21:06 
QuestionUserControl as a TabItem Pin
Tom Delany12-Jan-12 5:15
Tom Delany12-Jan-12 5:15 
GeneralRe: UserControl as a TabItem Pin
Tom Delany12-Jan-12 9:14
Tom Delany12-Jan-12 9:14 

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.