mvvm

How do I have a Silverlight databinding update the model as the user types?

I'm currently using Silverlight 4 and following the MVVM pattern. I have login boxes bound to my ViewModel like so: <PasswordBox Password="{Binding Path=Password, Mode=TwoWay}" /> I then later on have a button bound to a Command which listens to the ViewModel's PropertyChanged event and when one of the databindings has its data update...

Prevent WPF Frame from storing history in the stack

This seems like it would be an easy solution, but I'm wasting too much time trying to figure this out. Perhaps I am designing my application incorrectly (which might be the case), so please help me out if you have a better solution. I'm designing an enterprise level WPF application that looks a lot like Outlook with a Ribbon instead of...

ObservableCollection in Model + Threading in ViewModel

Our offsite development team created a Model with an ObservableCollection property. Now, I'm in charge of creating the ViewModel, and I'm having trouble because the said Model runs inside a BackgroundWorker (another thread)- which means I can't update the View by hooking the CollectionChanged events. Here's the workaround that I did: pr...

WPF reporting control that integrates well with MVVM pattern ?

Is there any WPF control (commercial or not) that integrates well with the MVVM pattern ? Ideally the report would be another View for the ViewModel. ...

In MVVM with WPF how to I unit test the link between the ViewModel and the View

In MVVM it is normal to connect View to the ViewModel with data binding. Therefore if the name of a properties changes on one of the Model objects that is databound to there is no compiler error. When the compiler will not stop a bug, the next thing I think of is “UnitTest”, However How do you unit test this without spending for...

ListBox CheckBox IsChecked binding using MVVM

I'm trying to figure out a way to bind my checkbox IsChecked property. Basically, I have a list of items which the ListBox is bound to. When a user checks the box, a command is invoked and that item is added to a collection. However, what if I want to programmatically select items in the list? I would like the IsChecked item to be ba...

How to active each view from Modules in CAL using MVVM pattern

I have a Shell application which loads different modules to it one at a time through a tab control attached Shell. I need only one instance of each module should be available in shell. So anyone can u help me how to activate and deactivate the views of each modules when user switches between tabs. Thanks in Advance. ...

Alternatives to Model View ViewModel for WPF

I've just been reading Josh Smith's MVVM article and am working on a WPF application at the moment. I'm umming and ahing about transfering my work so far to MVVM but find the idea of working purely through databinding and ICommands without any UI event handlers, a little daunting in the sense that it could take a while to convert what I...

Can't databind at design time in WPF using MVVM - ViewModel property never gets called

Ok, I'm pulling my hair out over this, so any help will be hugely appreciated! I'm building a WPF application using the MVVM pattern. In an attempt to get data in at design time I am using the Ninject dependency injection framework in conjunction with a service locator (much like the example in an article at http://jonas.follesoe.no/Yo...

Application Variable in WPF While Maintaining Testability

I am working on a WPF application, using the MVVM Pattern. Each ViewModel will need access to a security object, that essentially provides information about the rights the user has. Because this object only needs to be populated once at start up, and because populating it is (at least potentially) expensive, I want to keep it in state ...

MVVM UpdateSourceTrigger

I'm working on an MVVM app and have a view that is used to modify a number of network parameters (IP, SubnetMask, etc). The view contains a number of text boxes bound to properties in a 'NetworkConfigViewModel': <TextBox> <TextBox.Text> <Binding Path="IP" UpdateSourceTrigger="PropertyChanged"/> </TextBox.Text> </TextBox...

How to control the scroll position of a ListBox in a MVVM WPF app.

I have got a big ListBox with vertical scrolling enabled, my MVVM has New and Edit ICommands. I am adding new item to the end of the collection but I want the scrollbar also to auto position to the End when I call my MVVM-AddCommand. I am also making an item editable(By calling EditCommand with a particular row item) from some other part...

Importance of unit testing my Views when using the MVVM pattern?

When using the MVVM pattern to structure your WPF application you should get all your business logic out of the View and code-behind files. Doing it properly the View itself will be a simple facade with Data Bindings and Command Bindings to the ViewModel classes - which is where the magic happens. One key benefit from structuring your a...

WPF binding set before application starts does not notify?

In theory this code should provide me with a 300x300 window with a blue background from having the window's content bound to an object of type AstRootViewModel, however this doesn't seem to be the case. I'm wondering it this is happening because I don't call astApplication.Run() until after I set the mainWindow.ViewModel property. Usin...

WPF data bound ListView/ListVBox won't select if list only has one item

So this is pretty mystifying. I have a databound ListBox (or ListView, it happens with both), and if it has more than 2 items in it, selection works - I get a blue highlight bar and the item looks selected. If I only have 1 item, the selection does not work - I do not get a blue highlight bar, but the selection events all fire as normal....

Why isn't this Silverlight attached property working?

I'm trying to use the MVVM pattern in my Silverlight 3 application and am having problems getting binding to a command property of a view model working. First off, I'm trying to add an attached property called ClickCommand, like this: public static class Command { public static readonly DependencyProperty ClickCommandProperty = ...

CanExecute on RelayCommand<T> not working

...

Using MVVM, how can a ContextMenu ViewModel find the ViewModel that opened the ContextMenu?

I'm using MVVM to bind views to objects in a Tree. I have a base class that implements the items in my tree, and that base class has a ContextMenu property: public IEnumerable<IMenuItem> ContextMenu { get { return m_ContextMenu; } protected set { if (m_ContextMenu ...

Can I apply a ContextMenu to a ContextMenuViewModel using a DataTemplate?

I have a ViewModel (AbstractContextMenu) that represents my context menu (IContextMenu), and I bind a real ContextMenu to it with a DataTemplate: <DataTemplate DataType="{x:Type local:AbstractContextMenu}"> <ContextMenu x:Name="contextMenu" ItemsSource="{Binding Path=(local:IContextMenu.Items)}" IsEnabled="{Bind...

How to achieve clean code-behind files?

Working with WPF it is good practice to keep your xaml.cs code behind files small and clean. The MVVM pattern helps achieving this goal through Data Bindings and Command Bindings where any business logic is handled in the ViewModel classes. I am using the principles of the MVVM pattern and my code-behind files are rather nice and clean...