mvvm

How to create Views in MVVM

I'm using MVVM in a WPF application. I want the least possible code to exist in the view's code behind. All Views and ViewModels are registered in dependency injection engine and my Views have dependencies to their ViewModel (injected via constructor). In one of the command handlers of ViewModel "A", I need to show View "B". What's the ...

WPF M-V-VM: Get selected items from a ListCollectionView?

I've got a WPF app using the Model-View-ViewModel pattern. In my ViewModel I've got a ListCollectionView to keep a list of items. This ListCollectionView is bound to a ListBox in my View. <ListBox Grid.Row="1" ItemsSource="{Binding Useragents}" SelectionMode="Multiple"/> The ListBox has SelectionMode=Multiple, so you can select more...

Handling Dialogs in WPF with MVVM

In the MVVM pattern for WPF, handling dialogs is one of the more complex operations. As your view model does not know anything about the view, dialog communication can be interesting. I can expose an ICommand that when the view invokes it, a dialog can appear. Does anyone know of a good way to handle results from dialogs? I am speakin...

Silverlight and multiple viewmodels

I'm writing a Silverlight app using the MVVM pattern. I have a main view (UserList.xaml) and corresponding vm (UserListViewModel.cs). This is used to list a collection of users. I also have a UserControl (User.xaml - invoked as a modal dialog) that is used to add details for a new user. This also has a viewmodel of it's own (UserViewMode...

Implementing and using the ICommand interface, MVVM

Although I deeply fell in love with the MVVM pattern there seem to be a lot of problems I cannot (yet) figure out for myself. I wonder what the parameters of the methods of the IComamnd interface are good for e.g. void Execute(object parameter); I tie my view to the view model like this <Button Command="{Binding SomeCommand}" ... /> ...

Are there any good books on M-V-VM in WPF?

I've seen a lot of book recommendations for WPF here, but no witch is specific to MVVM. ...

WPF MVVM Newbie - how should the ViewModel close the form?

I'm trying to learn WPF and the MVVM problem, but have hit a snag. This question is similar but not quite the same as this one (handling-dialogs-in-wpf-with-mvvm)... I have a "Login" form written using the MVVM pattern. This form has a ViewModel which holds the Username and Password, which are bound to the view in the XAML using normal...

Implementing MVVM in WPF without using System.Windows.Input.ICommand

I'm trying to implement a WPF application using MVVM (Model-View-ViewModel) pattern and I'd like to have the View part in a separate assembly (an EXE) from the Model and ViewModel parts (a DLL). The twist here is to keep the Model/ViewModel assembly clear of any WPF dependency. The reason for this is I'd like to reuse it from executable...

How do I maintain coherency between model and view-model in MVVM pattern?

Problem Statement I'm writing a very basic WPF application to alter the contents of a configuration file. The data format is an XML file with a schema. I want to use it as a learning project for MVVM, so I have duly divided the code into Model: C# classes auto-generated from xsd.exe View-Model: View-friendly representation of the ...

What is the purpose of a Service Locator in a Silverlight MVVM app?

I am trying to put all the pieces together for my MVVM Silverlight application and I see some blogs touch on Service Locators. What is a service locator and when should it be used? ...

How do I pass a specific viewmodel object in a button's CommandParam?

I have a simple WPF program using the Master-Detail UI pattern, where the Detail shows the currently selected item of a collection in the Master pane. I'm using MVVM, and each XAML page is backed by a ViewModel object which is set as it's DataContext. Now, I want to add a DELETE button in the Master pane to delete from the master list ...

WPF Binding to a non-changing property

I'm using the MVVM pattern and I have a POCO (in my Model) with a Start Date property. I want to show the elapsed time since the start date in a control on a WPF window/user control... I don't see how I can bind a ModelView property to a UI control and have it update this duration automatically...can anyone suggest a way? I could use...

When to unhook events in Silverlight

One-line summary: What is the best practice for unhooking event handlers created in the constructor of a UserControl in Silverlight2? Background: I am currently building a line-of-business application in Silverlight2. As Silverlight is a browser plugin, there is no concept of a Window - everything is done within UserControls. The way I'...

How to share data between model and view?

I'm currently working on redesigning an application which is building a model from input data, and displaying that data to the user. The current system has a thread for building the model, a thread for building a visualization of the model, and a thread which displays the visualization. The problem I have is that pointers are passed betw...

Binding WPF ComboBox to a Custom List

I have a ComboBox that doesn't seem to update the SelectedItem/SelectedValue. The ComboBox ItemsSource is bound to a property on a ViewModel class that lists a bunch of RAS phonebook entries as a CollectionView, then I've bound (at separate times) both the SelectedItem or SelectedValue to another property of the ViewModel. I have added ...

How should I handle multiple events per control w/command pattern using MVVM in Silverlight?

Is anyone using the SLExtensions command pattern (http://www.codeplex.com/SLExtensions) for associating commands to Silverlight control events? From what I've seen, you can only attach a command for one event per control. For example, you can only add a click event for a button, a keydown event for a textbox, etc. What if I wanted to a...

MVP Pattern: should multiple Presenters be decoupled or can they communicate directly?

I have a ui that looks like this: +--------+---------------+ | model1 | model details | | model2 | here, | | model3 | loaded as the | | | user selects | | | a model from | | | the left. | | | | +--------+---------------+ I'm using the MVP patte...

Model View ViewModel in WPF with WebBrowser

Hi All Im writing an app in WPF using MVVM pattern, where Im restricted to binding to properties and commands exclusivley However, I want to use the WebBrowser control which can only take an html string for content as a parameter to a mthod, and not a property. I was going to create a new control derived from Webbrowser that has the r...

Binding to a command in a datagrid

I am using the M-V-VM pattern in a WPF app. I am binding a ViewModel to a COntentControl and using a data template defined int eh window resources to render the view (a UserControl) for that ViewModel. In the ViewModel, I have a collection of items. I'm binding that collection to the data grid provided in the WPF toolkit. Also in the...

Data structure for Double Elmination Tournament

I am in the process of converting my Tournament Organizer software, which allows the creation and manipulation of Double Elimination Tournaments, to use the MVVM design pattern so that it can be more easily tested. In doing so, I'm separating out the 'model' from some code in the UI that directly manipulates the bracket structure. This ...