mvvm

Silverlight UserControl and his own Viewmodel hosted in a View

I want to make a reusable UserControl as: A VIEW with its own VIEWMODEL where is the logic data recovery This UserControl (or View ?) has a button 'OK' to target a RELAYCOMMAND in his viewmodel I'm hosting this 'UserControl' in another VIEW ('MainPage'), who, herself, has its viewmodel My question is: How can I target the p...

Constructor Injection of an ObjectContext using Unity/Prism/MVVM

Hi there, I develop an application using WPF with MVVM pattern and Prism. The views are added to the ModuleCatalog and the viewmodels are registered to a unity container. For that I'm using a Bootstrapper which is responsible creating the shell, configuring the unity container and the module catalog. The question is now, how injecting m...

How should I access the underlying entity/model of a ViewModel

Hi, We're designing a WPF / MVVM application that allows the user to search and manipulate contact records. We have a MainViewModel that contains an observable collection of ContactViewModel objects, each one of which wraps a Contact entity returned from our business layer. The UI displays these in a list, with the SelectedItem propert...

Should a ViewModel in MVVM reference the View?

In the MVVM (Model-View-ViewModel) pattern should the ViewModel reference the view. I would think that it should not. But how should the following scenario be handeled? I have a view that has a tab control as the main container, the viewmodel for this view impliments a command to add a new tab to the tab control. The easy way would be to...

Silverlight bestpractices

My team is starting a new project in silverlight. We are all experienced developers. It should be out of browser application with usage of public api's. We read about MVVM pattern... Are there some other guidelines/best practices for silverlight? ADDED: What we would like to know is: Is there some other patterns/guidelines for SL oth...

How to approach loading displaying different views based on Selected Treeview Node

I need some guidance on the plumbing of an MVVM patterned app. Here's the setup. The page is vertically divided in two. The LHS has a treeview, and the RHS will display the details on whatever item is selected from the tree. The treeview items bind to a few different types of View Models (Customers, Vendors, Employees for example) Se...

WPF/MVVMDo I need a dependency Injection tool like Unity/LightCore when using a ViewModelLocator

Hello, I would like to use a ViewModelLocator and I would like to know wether it is a basic requirement using a DI framework to make a ViewModelLocator possible? ...

WPF optical style of dynamically created MenuItem-Separator in MVVM

I have have a MenuItem that creates its sub-menu-items dynamicly from the ItemsSource-property. For grouping, I have Separators in the menu. The separator is created for each null-entry in the ItemsSource-collection by a ControlTemplate of the MenuItem.ItemContainerStyle. This works fine, however has the separator not the same optica...

Treeview SelectedItem is sometimes the VM and sometimes TreeViewItem

I have a TreeView that the user navigates to select an item for display in a grid. Briefly the XAML looks like this: <local:TreeViewEx x:Name="theTreeView" ItemsSource="{Binding theData}"> <local:TreeViewEx.ItemTemplate> <sdk:HierarchicalDataTemplate ItemsSource="{Binding theChil...

Need a simple Example of cascading combo boxes using MVVM

Need a simple Example of cascading combo boxes using MVVM Wpf / Silverlight ...

How to dynamically discover all XAML files in all modules in a Silverlight prism app.

Is there an easy way to dynamically discover all the XAMLs files within all the currently loaded modules (specifically of a Silverlight Prism application)? I am sure this is possible, but not sure where to start. This has to occur on the Silverlight client: We could of course parse the projects on the dev machine, but that would reduce ...

Silverlight template selector solution works great, but not blend able.

Before I begin here is a reference to how I implemented a template selector with Silverlight. http://geekswithblogs.net/tkokke/archive/2009/09/28/datatemplateselector-in-silverlight.aspx Everything works great. But the solution just doesn't work in blends making things more difficult to visualize overall. Is the correct work flow to ...

MVVM- Where should I implement my save logic?

I have two different models that need saving; a TextFile object and a static Settings object. Right now, I have the save logic implemented in the models themselves. I like how clean this looks, when calling the save methods: Settings.Save(); and _currentFile.Save(filePath); However, from what I have read it sounds like I am sup...

Handling the window closing event with WPF / MVVM Light Toolkit

I'd like to handle the "Closing" event (when a user clicks the upper right 'X' button) of my window in order to eventually display a confirm message or/and cancel the closing. I know how to do this in the code-behind : subscribe to the "Closing" event of the window then use the "CancelEventArgs.Cancel" property. But I'm using MVVM so I...

WPF ListView.ItemsSource Binding Problem

I have a MainViewModel and Customers property (list of CustomerViewModel objects as an ObservableCollection) inside it. I want to bind that list as a ItemsSource to ListView Control. My MainViewModel is bound to Window's DataContext property. I used ServiceLocator pattern in order to create MainViewModel instance which gets an IDataServi...

Binding Observable collection

I have a collection in the main window and I want to show it on a grid in a user Control, What is the right MVVM way to do that ? I've done an observableCollection in the MainWindow And bounded it to an observableCollection in the usercontrol. and in the user control the grid is bounded to the collection. it doesn't work :( /// <su...

View visibility is not changing

I have a Shell holding 2 Views. They both use the same viewmodel, in fact the shell uses the same viewmodel as well. I have 2 buttons in the shell that are supposed to change the visibility of the the 2 views. It appears that even though the command is firing, that the value is being changed and that i have onpropertychanged configured c...

Unselect item from a ListBox so NotifyPropertyChanged is called when clicked

I have an ItemsControl with DataTemplates that contain ListBoxes with ItemsSource all bound to different ObservableCollections of the same type, each ListBox's SelectedItem is bound to the same property that raises PropertyChanged so that other visual elements of my UserControl will update with the SelectedItem's details. Everything wor...

Remebering State of Expand/Collapse of all the groups in ListView WPF

I have a ListView and implemented Grouping with the code below in XAML, <ListView.GroupStyle> <GroupStyle> <GroupStyle.ContainerStyle> <Style TargetType="{x:Type GroupItem}"> <Setter Property="Margin" Value="0,...

Call the repository`s CRUD-methods from the Controller or ViewModel ?

Hello all, thats the way josh smith is doing the add-a-customer-procedure: **CustomerViewModel**.cs: public void Save() { _customerRepository.AddCustomer(_customer); } **CustomerRepository**.cs: public void AddCustomer(Customer customer) { //... _cus...