mvvm

Problem with MVVM. Dynamic list of grids

Hi, I don't know according to MVVM show data on control. I have a collection of cars. I want group their by type (eg. Sedan, Combi, Hatchback) and depends of number of types print grids. So : 5 cars: 2 x sedan, 2 x Combi, 1 x sportcar. So I want to print 3 grids. How do it to be ok with MVVM. ...

MVVM Light Messaging

In terms of communicating different messages within an app would a good idea be to create a class for each message type? Some of my messages will need a reference a model object. For example DoThisMessageType: Messenger.Default.Send<DoThisMessageType>(_doThisMessageType); Messenger.Default.Register<DoThisMessageType>(this, delegate(Do...

Add EventToCommand to each Row in xaml

Is there a way to add a DoubleClickEvent to each Row in xaml rather than using the event of the datagridcontrol? Something like this (this code does not work): <UserControl xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;a...

How Testing relates to ASP.NET MVC/WEBFORMS Silverlight MVVM.

Ive been learning MVC2 and MVVM lately and I think it works like this. ASP.NET MVC2 - Can test the whole web site using unit tests ASP.NET MVC2 + jquery web service calls - Can no longer just use MSTest unit test. What is the MS product to test the javascript side? ASP.NET Webforms - Unit Tests are near impossible when the coder does...

Using commands to be notified that a collection has changed

Guys, I was wondering if there's any way i could handle when a collection changes and, after that, display a message to the user. As im using MVVM, i dont have any references to the model inside the view project, so i couldn't do MyCollection col = InstanceOfViewModel.Read(); Since View doesn't know anything about "MyCollection", a...

databinding to validation.haserror

I want to bind Validation.HasError to a boolean property on my viewmodel. I only want to know when there is a validation error so that I can disable my buttons on my VM using canexecute methods from my relay commands. I get this error though: 'Validation.HasError' property is read-only and cannot be set from markup. I have tried diff...

WPF/MVVM: Refactoring Code-Behind to make it ready for MVVM binding

Hello, I have this code in my code-behind file of my View: private string GetSelectedSchoolclassCode() { return ((SchoolclassCode)cboSchooclassCodeList.SelectedItem).SchoolclassCodeName; } private void dgTimeTable_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var columnNumber = dg...

MVVM with webservice

I'm going to do a wpf application using MVVM(It based on http://www.codeproject.com/KB/WPF/MVVMQuickTutorial.aspx ). This application will be connecting with webservice one per month. On webservice I have contract public class Student { public string Name {get; set;} public int Score {get; set;} public DateTi...

I need to find a common architecture for wpf and web forms

My shop is moving towards re-working the app to be a combination of wpf and web forms. Some functionality will be facing the public via web forms and some will be internal only via wpf. I'm trying to find a common architecture for both sides of the equation. From what I've seen so far wvvm is the best bet for the wpf side, but that doe...

WPF how to integrate Ribbon in prism applications

Hi, I'm writing a prism application and would like to integrate Ribbon library in it. I want a Ribbon Window that would be used as a Shell with office-like tabs and tab groups. The modules should be loaded on demand depending on the tab selected by user. I don't want the tabs to be located in a region if this is avoidable. So I created a...

mvvm wpf messenger class, unregistering messages

Hi guys, I am using Josh Smith's MVVM Foundation project Messenger class and just had a question regarding unsubscribing messages. At the moment I have multiple ViewModels which register messages as strings for example I have - ViewModelA - registers for message "A" ViewModelB - registers for message "A" So the both registered message...

WPF MVVM call ViewModel Save method on Window Close

Hello, I have figured out how to close Window from my ViewModel. Now I need to solve window close problem from the other side. I need to trigger Save() method in my ViewModel when the user clicks window's close button. I was thinking about binding Command property to Window's close event, but my ViewModel is related to the user cont...

Validation empty fields in MVVM

Hi, I have a XAML with about 100 controls. All of them are bound to class Student. I can validate such pool like Age, or Name, but how to validate controls,which user not even touch ? For example for field Address. Address couldn't be null, but user forgot about filling this control. ...

How to make ItemsControl choose different templates depending on run-time type.

I have a xaml page that has an ItemsControl control on it. ItemsControl is bound to Guests which is ObservableCollection. Guests collection can have objects of two different types: USGuest and UKGuest, both inheriting from Guest. Is it possible to make two (or more) templates for ItemsControl and make it automatically choose between them...

WPF MenuItem : Mix databound items and static content

Hi there, I'd like to build an MRU menu that has the following structure: File +=>Recent Files +=> Doc1.txt +=> Doc2.txt -separator- +=> Clear entries This being MVVM, my mru list is databound to the View Model. Because I want to add the separator, and I don't fancy inserting the separator and the clear entry action in th...

Type.GetType returns null when using MEF

I'm currently using MEF for a project to import plugins, as the plugins are written in WPF they each have a view and a viewmodel. The plugins know about the viewmodel but the main shell UI will construct the view and bind the viewmodel using a convention over configuration type pattern. I have used some code from the Build-your-own-MVV...

How do you implement a 'FileUploadCommand' using OpenFileDialog in Silverlight?

Ok, Wanting to MVVM an existing app. The code behind contains the following: private void UploadClick(object sender, RoutedEventArgs e) { /* * 1. Clear Messages (ObservableCollection) * * 2. Create new OpenFileDialog * 3. if(ofd returns ok) * Pass file to Interpreter */ } Basically, what I'd lik...

Silverlight ListBox - static plus bound items

Is there any way to have a listbox populated by both static and dynamic items? I am writing a windows phone 7 app and would like to have one static listboxItem at the top or bottom and then bind other items from the viewModel. I tried setting both a static listboxItem and then also a dataTemplate but the static item is replaced by th...

Sharing presentation logic between C# application with windows and web UIs

I need to build an application in C# that will have multiple UIs, 2 for web and one that will be the same application, but able to be used with no internet access. I am leaning towards MVC for web, then MVVM/WPF for the windows application (Silverlight is not an option). I should be able to inject a different repository implementation ...

how to fire Validation on a property of a calss used by a HierarchicalDatatemplate instead of firing it on my viewModel properties?

Hello Everyone. the problem i have is somewhat difficult to explain i will try my best: i am using a custom control called "TasklItem" (derived from Panel). this control renders itself hierarchically in a treeview using following HierarchicalDataTemplate: <Grid Name="TaskItemTempl...