mvvm

MVVM + Datacontext + DataTemplate + Blend = problems

Hi All, I'm currently using MVVM in a WPF project, all works very well. I have one Master view and many Detail views that I manage using a currentView property in my MasterViewModel. By using a datatemplate, I bind a view to a viewmodel. In fact, my master view has a contentcontrol whose content property is binded to my CurrentView prop...

WPF data binding and type conversion

I have a question regarding WPF binding and converting the data types seen by the UI objects in XAML. I have a user control that I would like to reuse in different applications. The user control displays a thumbnail image and several TextBlocks to display person demographic information such as name and address. The user control is used...

MVVM Questions: ViewModel/View relationship and validation

In our WPF application we want to use the basic MVVM pattern. We were discussing it and some uncertainties about ViewModel/View relationship and validation came up. Would you say the following is a good understanding of it? Every View has one and only one ViewModel and the ViewModel's purpose is to provide its View with data and handl...

Which Silverlight MVVM Test Project Type?

When creating a test project for a Silverlight MVVM application, should I create a standard C# test project - aimed at the ViewModel, or a Silverlight Test project aimed at the view, or (gulp) both... ...

MVVM Binding to InkCanvas

I seem to have ran into a road block. We are using MVVM with Prism and have a View that requires an Ink Canvas. I've create a StrokeCollection that is being bound from my ViewModel to the View. I am able to set the collection from my viewmodel but changes are not coming up to the ViewModel while the user draws. Is there a way to make...

Silverlight Unit Testing - How to check UI base types?

In short: How would I check the type of a UI user control during a Silverlight unit test? In detail: I am loading child views into a ContentControl on a parent view. During testing I want to check that the correct view has been loaded at the correct time. My views are in separate projects, and I don't want to add a reference to those as...

Silverlight MVVM Unit-Testing Explanation

Can anyone explain why, when I step through my unit tests with the debugger, that I get null references whenlooking at objects or properties. For example: 1 [TestMethod] 2 [Description("Test to confirm that upon initial class creation, the login view is loaded as the default content for the TaskRegion.")] 3 pu...

MVVM WPF - Usage of Viewmodels

Hi Guys, I am having a WPF dataentry form which has got 3 comboboxes which needs to be filled with Master Details like Department, Job Title and Pay Type & other information. All these 3 master information needs to be fetched from the database. I am using LINQ to SQL as my data layer. I have already built the maintenance pages for these...

Combining .NET RIA Services and MVVM in Silverlight 3.0

When using .NET RIA Services and MVVM in Silverlight 3.0 is there a difference between the Metadata type from RIA Services and the ViewModel from the MVVM pattern? Are these the same thing or should they be keep separate? The metadata type is a sealed internal class to the partial Entity class. There doesn't seem to be a proper separati...

WPF MVVM Binding Checkbox.IsChecked to a named item in a Dictionary<string, bool>

I have a group of checkboxes that all represent different selections of the same type (for my example, they are all different file types). I feel like binding each one to an individual property in the ViewModel is overkill, and I'd prefer to bind them all to one collection and use the binding syntax to bind each checkbox to a particular...

Silverlight MVVM ListBoxItem IsSelected

I have a collection of ViewModels bound to a ListBox. I am trying to bind the IsSelected properties of each together. In WPF it works by setting the style: <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" /> </Style> This does not work in Silverlight. How can I...

WPF MVVM + UserControl with Code Behind.

For some reason I'm having issues Binding a custom User Control up through my ViewModel in an MVVM WPF application. The basic control is a Date entry form with three text boxes. I am using the codebehind for the usercontrol to capture the textchange event and so some manipulation. For some reason Adding Binding to the property never t...

Silverlight child windows in MVVM pattern

Hello, I am trying to find the right way to get the data from a ChildWindow/popup using a MVVM pattern in Silverlight (3). For example: I have a main page with a data entry form and I want to open a popup with a list of customers. When user selects a customer I want to transfer selected customer into the main page. This is what the (exam...

How verbose should names be for Model-View-ViewModel (MVVM) classes and instances?

In general, I prefer to be verbose with .NET class and instance names, but some times (to quote Mike Woodhouse): Over-verbosity tends to conceal syntax, and syntax is important. The first place I felt like I really strayed into the over-verbosity regime is upon implementing the Model-View-ViewModel (MVVM) pattern in Silverlight and...

What is the metaphor behind CommandSink?

I'm working through Josh Smith's code and article on CommandSink which is a solution that simplifies using commands in an MVVM context, seems very useful. But I feel I am missing something about the concept by not understanding what the word "sink" is referring to, e.g. the commands sink past the code behind into the ViewModel? the co...

WPF MVVM: Convention over Configuration for ResourceDictionary ?

Update In the wiki spirit of StackOverflow, here's an update: I spiked Joe White's IValueConverter suggestion below. It works like a charm. I've written a "quickstart" example of this that automates the mapping of ViewModels->Views using some cheap string replacement. If no View is found to represent the ViewModel, it defaults to ...

Getting a reference to the ViewModel from an IValueConverter

Is there a clean and/or an accepted standard way of referring back to the ViewModel from an IValueConverter, or does that break the MVVM pattern? Basically, I want to convert bound data in the UI based on other properties of the ViewModel. I guess this is the same question as how do you refer back to the Window/Page from an IValueConve...

can someone explain this C# structure: base.Executed += (s, e) =>...

I'm working through Josh Smith's CommandSink Example and the base.Executed += (s, e) =>... structures are throwing me, can someone help make this crystal clear? what I understand: base.CanExecute is the event on the inherited class CommandBinding the += is adding a delegate to that event the delegate is the anonymous function which fo...

In MVVM should the ViewModel or Model implement INotifyPropertyChanged?

Most MVVM examples I have worked through have had the Model implement INotifyPropertyChanged, but in Josh Smith's CommandSink example the ViewModel implements INotifyPropertyChanged. I'm still cognitively putting together the MVVM concepts, so I don't know if: you have to put the INotifyPropertyChanged in the ViewModel to get Command...

WPF - Get Hyperlink command from data?

In WPF, how can I get a reference to the Command that a Hyperlink should invoke from an object property? I am creating a WPF application, using the MVVM pattern. A list box in the main window dislays hyperlinks. Each hyperlink will invoke one of the view model's ICommand properties when it is clicked. How do I specify which ICommand sho...