mvvm

MVVM Prism Nested Regions Can't Find Child Regions

I have a Menu (Telerik RadMenu) that has nested regions defined in the Shell. In my modules I will register the modules menu or toolbar items with these regions. Everything works fine for the root regions, but when I try and add something to a child region, such as the File region on the Menu, I get the error "The exception message was: ...

Passing parameters into ViewModels (Prism)

Hi I can't figure out how to pass parameters to my viewmodels from other views or viewmodels. For instance, I have a View called Customers. There is a grid inside, and if you double-click the grid, a new view is supposed to come up and allow you to edit that customer's data. But how will the View(Model) responsible for editing data kno...

Using MVVM, what to do when a control doesn't have a "Command" property?

In my program I need a way to click on an Image control, the program takes in the X,Y position of where the click took place, and then produce a rectangle around that position. My problem is that I'm using MVVM, so all my code is in a separate file (ViewModel file rather than the code-behind file). The Image control doesn't have a Comm...

How to implement menuitems that depend on current selection in WPF MVVM explorer-like application

I am new to WPF and MVVM, and I am working on an application utilizing both. The application is similar to windows explorer, so consider an app with a main window with menu (ShellViewModel), a tree control (TreeViewModel), and a list control (ListViewModel). I want to implement menu items such as Edit -> Delete, which deletes the curre...

Diagramming in Silverlight MVVM- connecting shapes

Hi, have I have a quesition regarding MVVM pattern in the uses case of diagramming. What I have so far is a list of Items which are my Shapes. ObservableCollection<ItemsViewModels> Items; and a Collection of Connection of Items ObservableCollection<ConnectionViewModel> Each ItemViewModel has an ID and a ConnectionViewModel has t...

How would MVVM be for games?

Particularly for 2d games, and particularly silverlight/wpf games. If you think about it, you can divide a game object into its view (the graphic on the screen) and a view-model/model (the state, ai, and other data for the object). In silverlight, it seems common to make each object a user control, putting the model and view into a sing...

WPF databind Image.Source in MVVM

I'm using MVVM and am trying to databind the Source property of Image to my ViewModel in such a way that I can change the icon on the fly. What is the best pattern to follow for this? I still have the flexibility to change my ViewModel to suit, but I don't know where to start in either the xaml or ViewModel. To be clear, I don't want my...

Starting an animation from the ViewModel in WPF/MVVM

I'm writing a MVVM app and have started putting in a few animations. I want to call something on the ViewModel which starts the a storyboard. This blog had a promising approach to it, but it doesn't actually work. The IDChanged handler never fires for some reason. I also found that you could start animations on EventTriggers, but I don'...

how do you implement Async Operations in C# and MVVM?

hi what is the easiest way to implement asynch operations on WPF and MVVM, lets say if user if user hits enter when on a field i want to launch a command and then return back while a thread will do some search operations and then come back and update the properties so notification can update the bindings. thanks! ...

Pass or Get a value from Parent ViewModel down to Sub-ViewModel?

I am using the MVVM Light framework as well as Unity for DI. I have some nested Views, each bound to a corresponding ViewModel. The ViewModels are bound to each View's root control DataContext via the ViewModelLocator idea that Laurent Bugnion has put into MVVM Light. This allows for finding ViewModels via a static resource and for contr...

Dealing with child window from the view and sending results to viewModel

Silverlight version : 4 Silverlight patter :MVVM Visual Studio template :Silverlight navigation application 1)How do I deal with dialogs on the views e.g childwindow gets opened when a button is clicked? 2) How should the color's picker(inside the childwindow) control's hex value be communicated to the viewmodel? ...

Get the value for a WPF binding

Ok, I didn't want a bunch of ICommands in my MVVM ViewModels so I decided to create a MarkupExtension for WPF that you feed it a string(the name of the method), and it gives you back an ICommand that executes the method. here's a snippet: public class MethodCall : MarkupExtension { public MethodCall(string methodName) { Method...

FxCop hates my usage of MVVM

I've just started to work with FxCop to see how poorly my code does against its full set of rules. I'm starting off with the "Breaking" rules, and the first one I came across was CA2227, which basically says that you should make a collection property's setter readonly, so that you can't accidentally change the collection data. Since I'...

MVVM View reference to ViewModel

I'm using MVVM in a WPF app. I'm very new to both. Let me state that I am not a purest in the MVVM pattern, I am trying to use as many best practices as I can but am trying to make what I think are reasonable compromises to make it work in our environment. For example, I am not trying to achieve 0% code in my View codebehind. I have a c...

Learning WPF and MVVM - best approach for learning from scratch

Hello, I've got about three years c# experience. I'd like to learn some WPF and the MVVM pattern. There are a lot of links to articles on this site but I'm getting a little overwhelmed. Would a sensible approach for a begginer to be forget mvvm for a while and just quickly learn a bit a of WPF, then come back to MVVM? I had a leaf throu...

Casting in MVVM Light CommandParameterValue

here is my Problem, I want to pass the integer 1 when this canvas is pressed. Every time I click the canvas, I get a An unhandled exception of type 'System.InvalidCastException' occurred in GalaSoft.MvvmLight.dll. Now I could make my life easier and just do the RelayCommand to accept a String instead of int but for the sake of learning. ...

problem with tabbed interface as mentioned in the article of josh smith

Hello guys, I've got a problem with my program. Here is the link: http://dl.dropbox.com/u/2734432/TabbedInterface.7z Once you have opened both tabs, you'll start losing the references to other collections of the current item in the view. That is because these IDs are nullable and once you switch over to the other tab they'll become nul...

MVVM- Trigger Storyboard in the View Model in Silverlight

I have a couple of Storyboards in my view that I would like to trigger from the ViewModel if possible. Is there a simple way or elegant way of doing this. Here is what I am trying to do. Person Clicks on a Button-->RelayCommand (In the ViewModel), the Relay Command should then play the storyboard. Also one more thing, I would like to a...

Why can't I Bind a viewmodel property to a dependency property of a custom control

I want to use a color picker in my wpf application and I saw a nice looking one on this codeproject page. The control works fine until I want to connect the control to a viewmodel. I created a small test program with this viewmodel: public class ColorViewModel : ViewModelBase { public ColorViewModel() { LineColor = Brush...

MVVM - RaisePropertyChanged turning code into a mess

New to MVVM so please excuse my ignorance. I THINK i'm using it right but I find my ViewModel has too many of these: RaisePropertyChanged("SomeProperty") Every time I set a property I have to raise that damned property changed. I miss the days where I could just go: public int SomeInteger { get; private set;} These days I have to...