mvvm

WPF Binding and Using Custom Sample Data in Visual Designer

Quick 1 sentence summary: I wrote a demo app [download src here][1] that doesn't properly display sample data in the Visual Studio Designer and I need help. After 6+ years developing in C# and WinForms, I've decided to use WPF in my current project. I've written a small demo application to teach myself and experiment with WPF (you can s...

Change ControlTemplate of ContentControl in View using MVVM

I have two resources Dock and Undock in my View which is a UserControl(Dock.xaml), Following is xaml code <Grid> <ContentControl Template="{StaticResource Dock}"/> </Grid> In DockViewModel there is property called IsDocked,if its true i need to apply Dock otherwise Undock template How to change the template in view using Vi...

WPF MVVM - query about designing Models based on XSD

hi there, I have a small WPF application based on MVVM priniciples. So far I had dummy Model classes created in my app. Now I plan to call a Web Service that uses XSD. Looking forward I would like to use these Xsd Types as Models. I can see atleast two way of doing this (could be more); for eg - add a reference to the Web Service. T...

How to Refresh a ListItem in WPF ListView ,CollectionViewSource in MVVM

I have an ObservableCollection assigned to People and have a PersonViewModel and a PeopleViewModel _people= GetAll().ToList(); List<Person> allPeople = (from person in _people select new PersonViewModel(person)).ToList(); AllPeople = new ObservableCollection<WorkOrderListItemViewModel>(allOrders); AllPeopleCo...

Silverlight/WPF: I Don't Want ICommand to Change Button's IsEnabled Property, Is this possible?

So say I have a button (MyButton) that binds to: public ICommand MyCommand { get; set; } I register this command with: MyCommand = new DelegateCommand<object>(DoSomething); Now if I do MyButton.IsEnabled = false; It doesn't do anything, i.e., the button is still enabled. I know that the command is causing this to happen because ...

How to handle selections in MVP/MVVM-backed GUI application

In a GUI app using MVP/MVVM, say the Presenter/ViewModel presents a list/collection, and one or more of the items can be selected at a time. Because other parts of the application could conceivably change as the selection changes, does the selection require its own Presenter/ViewModel? If not, how is selection best handled by a given Pre...

MVVM Light - WP7 Page/Application Events

Is there a way to use MVVM Light to handle application events like Closed, Deactivated, Activated, etc? ...

Pattern / Methodology For Dynamic ContextMenu Based on Collection of Objects

Hello: Background I have a TreeView that follows the MVVM design pattern and supports multiple selection by recording TreeViewItem selections in a List. As it stands there are several types of TreeViewItems available for the user to select. They are: Two Root nodes of type WorldFolder and MyDataFodler which can contain child Folder...

RelativeSource FindAncestor without static resource in MVVM?

I'm new to WPF and the MVVM pattern so I have some problems with my bindings. In a details view of a customer, I want to list some statuses in a combobox. In my ViewModel the customer is at the root level, and so is the list of statuses. When using a static resource, I can use: ItemsSource="{Binding RelativeSource={RelativeSource Fi...

DataTriggers firing when virtualized contaniers come back into view

I have a xamdatagrid which has a large number of rows. These rows are being virtualized by the xamdatagrid (in a "recycle" mode). My problem is that the data triggers which are associated with these rows seem to be firing when the rows come back into view. Has anyone else experienced this before? IS there some way of detecting a row ...

mvvm how to make a list view auto scroll to a new Item in a list view

I am using the MVVM pattern, I have a view which creates a new ViewModel, after the user clicks save, this view is closed and a seperate view is opened which Displays a collection of view models in a list view. This list view is sorted in alphabetical order, so the new ViewModel may appear at the bottom of the listbox, which is not imme...

"Resource with the name {Locator} cannot be found" Error when using mvvm-light user control

Hello everybody, i am using the mvvm light toolkit to create a WPF application. I created a user control and a corresponding ViewModel. I created a ViewModel property in the ViewModelLocator. I bound the user controls datacontext to the property in the Locator class. When i edit the User Control in Blend or the VS Designer everything se...

Why is param in this lambda expression?

The MSDN magazine article by Josh Smith on MVVM contains a lambda expression I don't completely understand. What is the purpose of param in this code? _saveCommand = new RelayCommand(param => this.Save(), param => this.CanSave ); Translated to my preferred language VB it's: Dim saveAction as New Action(Of Object)(Addr...

Silverlight MVVM : How to do Localization in the correct way ?

In normal Silverlight projects, localization in the xaml view is done using: Text="{BindingPath=ApplicationStrings.MyNewString, Source={StaticResource ResourceWrapper}}" My question is : how to do correct localization from labels when using the MVVM pattern? Is this done like described here ? In xaml view: Text="{Binding LblUsernam...

Silverlight MVVM Business Application : Where to place the resource files ?

The default Silverlight Business Application (VS2010) creates some resources files (ValidationErrorResources.resx and RegistrationDataResources.resx) in the Web project and creates links to these in the Silverlight project. But in the client Silverlight project there are also some resource files (ApplicationStrings.resx and ErrorResourc...

MVVM - In a list of objects, each containing a command, how can I get the appropriate command to fire?

Maybe I'm going about this the wrong way but in my view model I have a list of objects (CGCAppSwitchboardItem) that each contain a DelegateCommand property. My intention here is that each item (CGCAppSwitchboardItem) in my list would represent a module inside my solution whereby a call to the command will load a module. Or, better said, ...

Recommend best approach in this situation.

I'm experimenting with MVVM and I can't quite wrap my mind around it. I have a View (windows) that has several repeated controls. Let's say I have 4 textbox - button pairs. Their behavior should be the same, after pressing a button paired textbox says "Hello World!" I have tried several options I could think of: One ViewModel, 4 st...

How to validate child objects by implementing IDataErrorInfo on parent class

I am developing a WPF Application using MVVM Architecture. I am an amateur in WPF so bear with me.. I have two model classes. Parent class has an object of another (child) class as its property. (i mean nested objects and not inherited objects) For instance, consider the following scenario. public class Company { public string C...

Binding to a list control and finding views

I would like to bind a list control (like a ListView) in a view to a collection in a view model. The collection is made up of any number of view models which also have views designed to bind to them. While each view model in the collection will derive from a common base type, their derived types are different (as are the types of their...

WP7 SL - How can I use two different View Models in a View. One VM: Display, other for User input and acting on it

I am using ViewModelLocator pattern. I have the following situation: Page1<->VM1 => Navigate => Page2<->VM1 => Navigate => Page3<->VM3 => Page 4<->VM4 => Page 5<->VM5 I will show Page2 using VM1 but the controls that will take input w...