mvvm

How to cleanly get user input from the middle of model's method in Model-View-Viewmodel architecture?

Hi everyone, I am writing an app that listens on a network connection, and when some data arrive, it replies back, and depending on incoming data, it may need to ask user (show dialog) before replying back. I don't know how to do this cleanly in M-V-VM architecture: the events and binding to observable collections are nice if I need to ...

What is the relationship between INotifyPropertyChanged and DependencyProperty?

I'm building a simple UserControl example with DependencyProperties so that the properties of the control can be changed in XAML (code below). But of course in my application I don't want this control to have tightly-coupled code-behind, but instead the user control will be a view called "DataTypeWholeNumberView" and it will have its ow...

PasswordBox Binding

I'm just getting started with M-V-VM and WPF and having issues understanding some binding issues. I have a login page that has a ComboBox and PasswordBox. The ComboBox looks like this: <ComboBox Name="comboBox1" SelectedItem="{Binding Path=Username}"> This works just fine - my values get updated everytime the SelectedItem changes on...

Do a self handled event prevent the instance from being garbage-Collected ?

Hi, i read the answer of the question Do event handlers stop garbage collection from occuring?, but what happens when the publisher is the target ? To be more specific, i am using MVVM design for a WPF app. Model-View classes raise a NotifyPropertyChanged on every change. In some classes, i need to call a method when something is modif...

WPF ContextMenu

I am using mvvm in a wpf app. I have a ContextMenu inside of a listview and when I right click a listviewitem i want a contextmenu to display a list of Contacts. The following just gives me a contextmenu with no content. Can anyone tell me what I'm doing wrong? <ListView Grid.Row="3" ItemsSource="{Binding Path=Phones}" ...

Animating the background of a new record added to a XamDataGrid

Ok, I've spent 2 days trying to work out how to do this and have so far achieved a score of 'FAIL'. The design is this: A ViewModel class exposes a public ObservableCollection property called People. A XAML view is bound to this property The desired behaviour is this: Add a new Person to the ViewModel's collection The View animat...

Undo inside WPF M-V-VM, how does it fit?

In my previous projects, I have already implemented undo system in c++, and I know how it work. I am also aware of the Command pattern. I will be implementing a C#/WPF desktop application and would like to base my design on the M-V-VM pattern. The application will: be relatively a small project (2-3 weeks estimated work for 1 dev)...

RelayCommand lambda syntax problem

I am applying the MVVM pattern per Josh Smith and having difficulty. I've been researching the problem here and can't seem to get the syntax quite right. The code below looks to me like it follows the required syntax, but Visual Studio reports error "Delegate 'System.Action' does not take '2' arguments" on the line indicated. Can some...

How do you keep view logic out of the model and business logic out of the view-model in MVVM?

I can't quite figure out how to get the view model to be notified of changes in the model without adding a bunch of UI specific stuff like INotifyProperyChanged and INotifyCollectionChanged in my model or create tons of different events and do a bunch of things that feel like they're UI specific and should stay out of the model. Otherwi...

Confusion regarding MVVM pattern and dynamic loading of XAML in GUI.

Well this question relates to MVVM pattern and i could good and fast answers on this forum so I thought to ask and clear the confusions i had about the pattern. I am quite new to MVVM approach. I appreciate the pattern and understand the principals behind it. Maybe I have not worked that much with the pattern that’s why there are a few ...

How can I avoid this infinite loop?

It feels like there must be some semi-simple solution to this, but I just can't figure it out. Edit: The previous example showed the infinite loop more clearly, but this gives a bit more context. Check out the pre-edit for a quick overview of the problem. The following 2 classes represent the View-Models of the Model View View-Model (...

MVVM Visual Studio template installed but doesn't show up in template list

I installed the MVVM Visual Studio Template. It now appears in: Visual Studio C# Express 2008 (English) but not in: Visual Studio 2008 (German) Visual Studio 2005 (German) I reproduced this on another machine as well. Has anyone been able to install the MVVM Visual Studio template in a full version of Visual Studio in any langu...

WPF Prism V2 Using M-V-VM - Add a view at runtime to a region from the ViewModel

Hi All, Hopefully quite a simple one, having my first try at WPF with Prism V2 using M-V-VM and so far finding everything pretty awsome. My Shell is pretty simple, Ribbon Control at the Top, DataGrid of Help desk tickets on the left, and a TabControl on the right. When a user opens the selected ticket from the datagrid, I want the Tic...

WPF DataContext does not refresh the DataGrid using MVVM model

Project Overview I have a view which binds to a viewmodel containing 2 ObserverableCollection. The viewmodel constructor populates the first ObserverableCollection and the view datacontext is collected to bind to it through a public property called Sites. Later the 2ed ObserverableCollection is populated in the LoadOrders method and t...

WPF Basics: Shared global styles for MVVM

Hi, I am attempting to use an MVVM-ish approach to my WPF development. I have my logical view model classes under the ViewModel namespace, and I have matching styling for these view model classes under the View namespace. For now I have my View information in ResourceDictionary XAML files, as DataTemplates and Styles, which are all me...

Using element to element binding in Silverlight 3?

I don't really see the need for element to element binding in Silverlight 3 if using MVVM. Won't having one property directly affect another proper cause that property to be untestable? To me, it makes more sense to do a two way binding to a explicit property defined in the ViewModel. ...

Passing the current mouse position to a ViewModel?

Hi, In my MVVM application, I have a Direct3d render window that shows a bunch of 3d meshes in a scene. In that render window, I want to be able to click on one of those 3d meshes in the scene and move it around, having it follow the mouse cursor. This is typical 3d editor stuff, moving a mesh along in screen space. So I need to be able...

What are the three top Blogs for WPF?

I have several bookmarked, but only have so much time in a day to read/study blogs. If I were to pick three blogs to read on a daily basis for deep understanding of WPF what should I read? ...

What, if any, technology is going to replace ASP.NET?

WinForms has given way to WPF and new models such as MVVM, that better enable Test Driven Development, work very nicely with WPF. Also, it seems to me that ASP.NET is very closely aligned with the WinForms way of doing things, for example event handlers in the code-behind which is linked using inheritance or partial classes. With WPF a...

How do I pass the information from View to ViewModel with DelegateCommand?

In my View, I have a button. When the user clicks this button, I want to have the ViewModel save the context of the TextBlock in the database. <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top"> <TextBlock Text="{Binding FirstName}"/> <TextBox Text="Save this text to the database."/> <Button Content="Save" Comma...