mvvm

WPF+MVVM: How to display VM via resource dictionary

At the moment I am creating new instance of both View and ViewModel and assign view.DataContext = vm in the application in the handler of 'Startup' application event In the http://msdn.microsoft.com/en-us/magazine/dd419663.aspx in the "Applying a View to a ViewModel" chapter I've read that it would be a good idea to bind ViewModel objec...

Object reference not set to an instance of an object in ViewModelLocator Mvvm Light

Hi, I have multiple viewModels in my application and am binding/used them in ViewModelLocator mvvm light. I have done button on one of my DailyActivities.xaml page. but when i clicked on it,it gives me error in ViewModelLocator like "Object reference not set to an instance of an object". and control comes to this line : public static v...

Silverlight DataGrid and Binding columns

Hi I have a silverlight datagrid control and columns autogenerate property is set to false. I am using MVVM and wants to bind the columns collection. The data which i get is from xml. Something similar to sample code http://blogs.msdn.com/b/deepak_verma/archive/2008/07/19/dynamic-creation-binding-of-silverlight-datagrid.aspx Now by...

MVVM question, Event fire in the View

Hi All, I am new in MVVM and WPF. so be easy with me. I have a model (model A) in MVVM, in the ViewModel I have a collection. The collection is present in the View as ListView. I have another model (model B - not ui model) that need to do something every time that the listview is changing. How can I alert model B on the selection chan...

Swapping images on button from database using mvvm light

Hi, I want to swap images on the button dynamically using mvvm light. When the page first loads,it should display the images as per the database values i.e. checked or unchecked. I have 2 columns for the images like ImageChecked and ImageUnchecked. By clicking on the button i.e checked or unchecked it should change accordingly.If it che...

Attach command with parameter to KeyUp event

Hi, I am currently transforming a medium size WPF project to MVVM and I ran into a problem that I wasn't able to solve, yet. Maybe you could help me out? The target framework is .NET 3.5.1. I have a list view that gets its items from the underlying view model. That view model is exposing a command to remove the selected items from the...

Having trouble deciding how to wire up a UserControl with MVVM

I've been doing the best I can to try to stay true to the separation recommended by the MVVM pattern. One thing I haven't figure out how to do correctly has to do with initializing my UserControls. My most recent example of this has to do with a library that I wrote to talk to some low-level hardware. That assembly happens to have a U...

MVVM simple question

Problem - user clicks "do something" button (view), view model receives command and passes it to model (function call). Some time passes and model is done processing data (async). How does model notifies viewmodel about "need update"/"done"? What is the best aproach? How can i seperate Model from ViewModel in this scenario? ...

Master-Detail Split Between Two View Models: Where to put cancel command logic?

Hello, Master section of window contains a DataGrid. Details section displays a form allowing editing of record currently selected in master's DataGrid. Grid's SelectedItem is bound to the master vm. When that property changes, the master vm creates a new EditViewModel, exposing it via a property. The details section of the view uses th...

How to prevent Silverlight RIA Entity getting attached to datacontext before i'm ready

I have a Silverlight 4 application for a simple 'TODO' list. The problem I'm having is that databinding is hooking up relationships on my TODO object, which causes the RIA data context to add it to the DataContext.TODOs list before I want it there. I want to treat the object as new and detached until I'm explicitly ready to add it to th...

wpf mvvm is it possible to have a listview with a list of objects, and below it a view containing the item selected

I have a listview, which displays a list of administrators, this list is held within a gridview, and each column has a edit button bound to the object. Below this I have a seperate view, which is used to edit/create new administrators, what I want to do is bind the controls of this view to the Administrator selected in the Listview when...

How do I bind an inherited attached property value to my VM?

I have defined a custom attached property as follows: public class DataFilter { public static readonly DependencyProperty FilterColumnProperty = DependencyProperty.RegisterAttached("FilterColumn", typeof (string), typeof (DataFilter), new FrameworkPropertyMetadata(string.Empty, ...

WPF Merge ItemsSource Lists

I am working with a 2 lists in a backend class. Each list is a different type. Would like to present the user with a single list (containing a union of both lists) of which when an item in this list is selected the item's details appear. The code will look something like: My backend class looks somethings like this public ObservableC...

Adding runtime label as content in checkbox wpf

Hi, I am dynamically creating the checkboxes at runtime and also applying the style at runtime. Designer has developed a checkbox like control that am applying at runtime. and he put a Label on that checkbox control to show the Text on the checkbox control as its content from the Database. But when i applying content of checkbox or labe...

TreeViewItem.Expanded

Im using the latest version of mvvm light toolkit, however i'm not clear how I can use EventToCommand for the event TreeViewItem.Expanded. THis dosent work... what am I doing wrong? <TreeView Grid.Column="0" Grid.Row="0" ItemsSource="{Binding Path= MonitoredDatabases}"> <TreeView.ItemTemplate> <HierarchicalDataTempl...

How to make a Wpf datagrid cell numeric only ...

Is there an easy way in the xaml for a form (e.g. like a xaml attribute that I can place on a DataGridTextColumn) to force a datagrid cell to be numeric only? ...

C# MVVM TreeView TwoWay-Binding of hierarchical data

I googled for an answer to this for more than two weeks now. This usually means either I am blind or the idea is absurd. Anyways: In a middle-sized, quite flexible project I'm storing configuration data in a hierarchical structure in the like of this one: Configuration (collection) Audio (class) BaseDir (struct) PlayMode (enum) Inpu...

How can I make the Visual Studio debugger more useful when using the MVVM Foundation Messenger?

I've been generally very pleased with the MVVM Foundation Messenger, but I've noticed that when a messenger call causes an exception, the Visual Studio debugger doesn't ever seem to take me to the line of code that caused the exception (instead, it jumps to the method in the Messenger class that invoked the action). This forces me to do ...

Multiple ViewModels associated with a single view

I have a View that displays a DataGrid which is bound to an ObservableCollection in the ViewModel. For the sake of discussion, let's say we have a Team View containing a Team DataGrid, in which each row represents a Player. My question is about what data type I should use to represent the players in my Team collection. Is it a good ...

Wpf Bind View to ViewModel add to wpf window

I have a view that contains a ItemsControl with some textblocks inside to display the name and other information. in my window I am adding the view to the window as follows and in the code behind of the window i am binding the datacontext of the view to the view model in the MainWindow Loaded event as follows ViewOwnerSideBar.Dat...