Silverlight file dialog mvvm




















I am currently working on a SilverLight 3 Application. I have everything working except the following item. On one of my views I have to use an OpenFileDialog. I attempted to do this in the ViewModel only to find out the security model of SilverLight prohibits it because it is only allowed to be user initiated.

I've since moved the OpenFileDialog code to the code-behind of the View. Here is my problem though. Although I have binding to the source set to TwoWay it is not hitting the setter of the property in my ViewModel.

At least in Silverlight 2, I think the following rule might explain why you are seeing this behavior. Ok this is a hack but it works. This works and still renders the UI the way I expect. Stack Overflow for Teams — Collaborate and share knowledge with a private group.

Time to cast your vote for Telerik! Telerik is nominated in a total of 25 categories. Telerik UI for Silverlight. This is a migrated thread and some comments may be shown as answers. Sandro Top achievements Rank 1. Sandro asked on 26 Apr , AM. I want the button to call the RadUpload. Thank you in advance. Add a comment. It converts the data of the model into a format which is most convenient for the view.

If you search the Internet - or most probably Stackoverflow - for that question you will find many proposals how to address this challenge. I want to keep the view logic separated. I want the view as declarative as possible. The approach works as follows:. This example would open a default confirmation dialog with the specified title and content.

Once the dialog is closed the result is passed to the delegate given to the Raise method. Add void method CloseDialogWithResult to close dialog window:. Modify OpenDialog method in DialogService - add result variable and set its value to UserDialogResult property of hosting window data context:. At this moment our dialog returns a result of type DialogResult. Modal YesNo dialog will open. Click Yes or No button, dialog will be closed. Project flow will stop at break point and result variable will have a value, depend on which button was clicked.

PART 5. Modify signature of OpenDialog method in DialogService and add second parameter of type Window , set Owner property of DialogWindow instance to parameter value:. PART 6. Create subfolder DialogFacade in Dialogs folder. Add public interface IDialogFacade :. Install Ninject Nuget package.

Add IoC subfolder to project root folder. Add new class and name it Module , add two usings to work with Ninject:. Derive Module class from NinjectModule abstract class and implement it:.

Add new class Container and implement access to Ninject kernel using singleton pattern:. Change DataContext property in MainWindow. View All. Aleksei Pavlov Updated date May 09,



0コメント

  • 1000 / 1000