mvvm

Design suggestions for handing mutilple modes in Form

Hi Experts, We are designing one form in WPF which will have 5 modes. Now the question is that should handle these 5 modes in the same form by defining one form enum and manipulating the visibility of the controls. One thing to be noted is that as the mode goes on changing..complexity is going to increase for handling these modes. No...

Silverlight Datagrid column EventTrigger

I have a datagrid with multiple columns. I want to use Interaction.Triggers as a means to fire off a particular method on the view model when only one particular column on the grid changes. How do I find the list of available events for that particular column. I tried using Exp. Blend 4 but I could only see events for the entire datagrid...

Entity Framework - how to raise OnChanging for any property?

In a WPF / EF4.0 / MVVM app I have a View that edits a Customer entity. What is the best way to set a property "bool IsCustomerInEditMode" in my CustomerViewModel short of acting upon OnChanging/OnChanged partial methods for every single individual property of the Entity? As far as I know there's no OnEntityChanging method... Thanks! E...

WPF & MVVM : best architecture for Time-consuming search results ?

I am designing the architecture for a module where a search takes place. the search takes some time, and I would like to have the UI to be responsive, so I get to delegate the retrieval of the data to a class that will do the search on a separate thread. Then, I can think of two options : either 1° : the search method returns a view...

How to select datagrid's specific row using ViewModel for given row number say: make row no 2 selected in datagrid?

I am using MVVM light with silverlight 4. I am using EventToCommand to get selected rows from the datagrid. However i am not able to do it in reverse way i.e. from some defined value say 2 in view model how can I ask to place selection to row no 2 in the datagrid on view?' My scenario I am using it for inserting new data in database. Fr...

MVVM pattern in wpf - one data model , multiple view models

I am currently designing simple editor as part of learning process. Its basicaly hierarchical tree structure of polygons-lines-points, that is implemented in data model. I need to display these data in two views First view: hierarchical data in tree view item Second view: rendered geometry on screen Following the MVVM pattern i have ...

Can Lucene.NET be used with MVVM?

Just a quick pre-emptive question before we start to seriously investigate using Lucene. Currently building a C# WPF application, using MVVM and Microsoft Entity framework. My lead has brought up the point that this might represent a problem with us not being able to let Lucene directly access the database, and therefore there might be ...

Populate one combobox based on selection of another

I am learning wpf mvvm and have been struggling with what I feel is probably simple but have not been able to resolve on my own. What I want is to be able to select an item in a populated combobox and then populate another combobox based on that selection. I can't seem to get the second combobox loaded in response to a selection. I'...

Close Unmanaged Resources when WPF Application Closed

I'm currently having some trouble with an MVVM WPF application. In the application, the ViewModel is associated as the DataContext for a View using a DataTemplate in a ResourceDictionary - this way neither object has an in-code reference to the other. My ViewModel has an unmanaged resource which needs to be released when my ViewModel is ...

How to Bind Flags Enums To ListBox In MVVM

Hi, I want to bind an enum which has flags attribute to a listbox with a check list box item template in mvvm pattern? How can I do this? [Flags] public enum SportTypes { None = 0, Baseball = 1, Basketball = 2, Football = 4, Handball = 8, Soccer = 16, Volleyball = 32 } <ListBox Name="checkboxList2" ...

Data Binding in WPF control doesn't pick the new data from IPropertyChangedNotify call.

Project Overview Basically I was creating WPF application using MVVM pattern. However I had a thread which was updating my Data Model, so ViewModel, had to be notified about these changed and I needed a Notification mechanism in my Model. That would make my app make propagating notifications from one class to another, so I decided to Ha...

WPF: Command parameter for a delete command in a list

In my viewmodel, I have a list (ObservableCollection) containing items. In the view, this list is displayed in an ItemsControl. In each row, there is a "Delete" button. I want the command behind the button to remove the item from the list. <ItemsControl ItemsSource="{Binding myList}"> <ItemsControl.ItemTemplate> ... ...

KeyDown problem with Silverlight & MVVM

First of all, I am new to the Silverlight + MVVM world. So I will try my best to explain the scenario to you guys. I have the following AutoCompleteBox in my Silverlight 4 application which works perfect. <myControls:AutoCompleteBox Name="acbVendorID" MinimumPrefixLength="2" ItemsSource="{Binding VendorCodes, Mode=TwoWay}" ...

Change view when selected ribbon tab item changes

I'm using Fluent ribbon in a MVVM application. For each tab item I associate a view and a view model (set a new DataContext). How can I change the view and the view model (DataContext) each time when the selected tab item is changed ? It would have been nice to have an event that fires each time a tab item is selected, like Microsoft Rib...

How do I track all instances of a DataTemplate, or a control within a DataTemplate?

I'm using a DataTemplate to apply a View to a ViewModel. I have a case where when a certain thing happens in one instance of the View (DataTemplate), I need to take an action in all other instances. I'm already accomplishing this by implementing the Initialized event on one of the controls in the DataTemplate, and using that event to a...

Silverlight: how to bind List<T> to data grid.

MVVM pattern is implemented in my Silverlight4 application. Originally, I worked with ObservableCollection of objects in my ViewModel: public class SquadViewModel : ViewModelBase<ISquadModel> { public SquadViewModel(...) : base(...) { SquadPlayers = new ObservableCollection<SquadPlayerViewModel>(); ... ...

MVVM setup design time services?

Im working with the MVVM pattern + a simple ServiceLocator implementation, now to my problem how am i supposed to setup the services when the views are running in design time? Iv tryed this but it does not seem to work in VS 2010 or some thing, i know it worked on my old computer but on my new it does not. so does any one know a good al...

How do you manually refresh a window in WPF?

I'm using the ICommand interface to perform binding on a couple of buttons in my application, the Run and Close button. I'm using a helper method that was mentioned in this question to hook up the ICommand to a delegate as follows: _someCommand = new DelegateCommand(this.DoSomething, this.CanDoSomething); private ICommand _someCommand;...

How to hookup TextBox's TextChanged event and Command in order to use MVVM pattern in Silverlight

Recently, I realized that MVVM pattern is so useful for Silverlight application and studying how to adopt it into my project. BTW, how to hook up the textbox's textChanged event with Command? There is Command property for Button, however Textbox has no commapd property. If Controls don't have command property, how to combine ICommand an...

How to Achieve Lazy Binding of Tab Page Controls in WPF?

Hi, I have an entity class. This entity has lots of properties and entity's data is shown to the user in several tabpages of a tab control. I also implement mvvm approach. When the screen is shown to the user first, I want to bind only the active tab page controls and when the user navigates through tab pages seperate bindings will b...