mvvm-light

How to tell which dataform button ended edit when using EventToCommand

I'm new to SilverLight and Mvvm-Light. I have a DataForm on my view that displays/edits a SelectedPerson property (a Person object) of my view model. I want to execute a command on my viewmodel when the user clicks the Save button but don't want to take action if the user clicks cancel. I added the following to my ViewModel: public Re...

WPF MVVM Get Parent from VIEW MODEL

In a MVVM WPF application. How do you set a second windows parent from the ViewModel? example: view1 viewModel1 viewModel1's command calls: var view2 = new view2 view2.Owner = <----This is the problem area. How do I get view1 as the owner here from the viewModel? view2.Show() EDIT: See accepted answer below, then read the follo...

How do I keep my DataService up to date with ObservableCollection?

I have a class called CustomerService which simply reads a collection of customers from a file or creates one and passes it back to the Main Model View where it is turned into an ObservableCollection. What the best practice for making sure the items in the CustomerService and ObservableCollection are in sync. I'm guessing I could hooku...

Dynamically specify and change a Silverlight DataGrid's columns during runtime (MVVM)

What's the best method of dynamically specifying DataGrid columns in the Silverlight DataGrid control at runtime following the MVVM pattern? What I'd like to do would be bind the "DataGrid.Columns" property to a property in my ViewModel so that, if the user adds/removes columns, I simply update the ViewModel property and the DataGrid wo...

Is MVVM pointless?

Is orthodox MVVM implementation pointless? I am creating a new application and I considered Windows Forms and WPF. I chose WPF because it's future-proof and offer lots of flexibility. There is less code and easier to make significant changes to your UI using XAML. Since the choice for WPF is obvious, I figured that I may as well go...

Remove SelectedItems from a ListBox via MVVM RelayCommand

I have a list of items in a WPF ListBox. I want to allow the user to select several of these items and click a Remove button to eliminate these items from the list. Using the MVVM RelayCommand pattern, I've created a command with the following signature: public RelayCommand<IList> RemoveTagsCommand { get; private set; } In my View, I...

Can't use Visual Studio 2008 Designer with MVVMLight V3 SP1

I wish I knew what I did to cause this, but I cannot use the Visual Studio 2008 Designer at all with with MVVMLight templates. I receive a "Could not create an instance of type 'ViewModelLocator'. in any of my xaml pages. The application builds and runs fine but only the designer is broken. In the App.xaml is <Application x:Class="Ex...

Is it possible for the View to subscribe ViewModel CLR event?

Sometimes a view model needs to raise notifications, that a view should handle and do something in response, esp. when these can't be modeled as properties and property change notifications. Anything in MVVM Light that can allow the view to listen to events and translate view model notifications into user interface actions via declarati...

Bind selected value on combobox to view model

Hi, I have my silverlight app which pulls data into a datagrid from a view model. The vm is exposed via Mef. I also have a details grid which has comboboxes. The vm also contains the data to populate the combobox values. Upon first load, everything works fine and the selected items on te comboboxes are correct and I can select alternati...

Silverlight MVVM conversion from WPF

I was reading this article - http://msdn.microsoft.com/en-us/magazine/dd419663.aspx And I came across this piece of code in the WPF Demo application that came with the article. This template applies a CustomerView to an instance of the CustomerViewModel class shown in the main window. <DataTemplate DataType="{x:Type vm:CustomerViewMod...

how to create and track multiple pairs "View-ViewModel"?

Hi! I am building an application that is based on MVVM-Light. I am in the need of creating multiple instances of the same View, and each one should bind to its own ViewModel. The default ViewModelLocator implements ViewModels as singletons, therefore different instances of the same View will bind to the same ViewModel. I could create ...

MVVM - Master/Detail scenario with Navigation and Blendability

Hi, I'll start off with what I want so it may be simpler to understand: I have a Page (Master.xaml) that has has a listbox of PersonViewModel. When the user selects a PersonViewModel from the listbox, I want to Navigate to a details (Details.xaml) page of the selected PersonViewModel. The details page does some extra heavy lifting th...

MVVM Light Toolkit sample with RibbonControlsLibrary

I've just started playing the "MVVM Light Toolkit" and I'm wondering how can I merge RibbonCommand and RelayCommand Is there any sample that mix MVVM Light Toolkit and RibbonControlsLibrary? Many thanks Claudio ...

Silverlight Multiple Application / MVVM-Light ViewModelLocator

Hello, I am running into issues with registering a StaticResource where the ViewModelLocator class is located in a ChildApplication that is dynamically loaded by a HostApplication. HostApplication ClientApplication1 ClientApplication2 ... ClientApplicationN Each ClientApplication has a reference to HostApplication, but not the other w...

MVVM-Light and WebBrowser Control

My view has WebBrowser control in it, how could its ViewModel navigates to a URL and get the WebBrowser.Document object? ...

Silverlight 4 + MVVM + KeyDown event

I'm trying to build a sample game in Silverlight 4 using the MVVM design pattern to broaden my knowledge. I'm using Laurent Bugnion's MvvmLight toolkit as well (found here: http://mvvmlight.codeplex.com/ ). All I want to do right now is move a shape around within a Canvas by pressing specific keys. My solution contains a Player.xaml (...

How do you send in the LayoutRoot into a RelayCommand via a EventToCommand?

Grid example with the trigger: <Grid x:Name="LayoutRoot" DataContext="{Binding ProjectGrid, Source={StaticResource Locator}}"> <i:Interaction.Triggers> <i:EventTrigger EventName="Loaded"> <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding LoadedCommand, Mode=OneWay}" PassEventArgsToCommand="True"/> </i:EventTrigger> </...

Using the MVVM Light Toolkit to make Blendable applications

A while ago, I posted a question regarding switching between a Blend-authored GUI and a Visual Studio-authored one. I got it to work okay by adding my Blend project to my VS2008 project and then changing the Startup Application and recompiling. This would result in two applications that had completely different GUIs, yet used the exact...

Simple Binding question, unable to bind to button command in a DataTemplate using MVVM Light Toolkit

I've been attempting to bind to buttons within a DataTemplate without much success. The button does not fire. Button Click works successfully outside of the DataTemplate. Yet if I create a Click="button_click" the click button is fired. The Button Content binds perfectly as well. Example to illustrate.. ...

MVVM Light Messenger Class

Can anybody provide samples/links/simple-illustrations/videos/demos on how to use the messenger class in MVVM Light? ...