mvvm

WPF Dispatcher, Background worker and a whole lot of pain.

Ok this may be really simple but everything I try just seems to hit a brick wall. I have a view model with two properties, which are bound to my WPF form: bool IsWorking {get;set;} ObservableCollection<OtherViewModel> PendingItems {get;set;} I have a method that I call to fetch some new pending items from outlook, however I also wh...

ViewModel communication question

Imagine I have a UserControl that shows a parking lot (my favorite analogy) with cars of different colors. You can select a car, and in a separate UserControl (in a separate project) statistics of the selected car are displayed. Now a user wants a button on the car statistics UC, 'Next car of same color'. When selected it should show ...

MVVM: How is the model view supposed to communicate with the data model.

I'm learning about MVVM and one of the things I don't get is how the model and the view model are supposed to communicate. I also don't understand whether they are separate classes, composite classes, or whether the ModelView is supposed to inherit from the model. I need to get some data from a web service, so I think the model should b...

MVVM and the TextBox's SelectedText property.

Hi all. I have a TextBox with a ContextMenu in it. When the user right clicks inside the TextBox and chooses the appropriate MenuItem, I would like to grab the SelectedText in my viewmodel. I have not found a good way to do this the "MVVM" way. So far I have my appliction utilizing Josh Smith's way of MVVM. I am looking to tranfer...

How to use MVVM and MEF with DataTemplate?

I am trying to use MEF on a new project within my application. Things work at the main app level, but in this separate project whose assembly is included in the main app (its a UserControl) I am wondering about something... If I have a UserControl, and in it I have the following: <UserControl.Resources> <DataTemplate DataType="...

How to implement CRUD Master Details on the same screen under MVVM

I have a MVVM (Prism) application that I need to implement a master details screen wheer the master is a listview and the details is displayed next to it. Read-only seems easy enough (haven't done it yet but I've got my head around WPF binding) but edit/add confuses me. How to I make it so the master is not updated until the details is...

How to scope NHibernate sessions and transactions in a WPF application

I am relatively new to both WPF and NHibernate and attempting to build an application that combines the two, using the MVVM pattern. However, I am struggling to understand when and where my application should open and close NHibernate sessions and transactions. From what I have read, it is recommended that sessions should be kept as sho...

MVVM Multiple Command Handlers

My Application layer uses DialogPresenters to show some ViewModels in various dialogs (modal, splash screen, etc..). public DataImportDialogPresenter(DataImportViewModel viewModel, IDialogView shellView, IDialogView owner) : base(viewModel, shellView, owner) { //Base sets the view data context etc. //Moni...

MVVM/ViewModels and handling Authorization

Hey guys Just wondering how how people handle Authorization when using MVVM and/or View Models. If I wasn't using VM's I would be passing back the Model and it would have a property which I could check if a user can edit a given object/property but when using MVVM I am disconnecting myself from the business object... and thus doen't ...

What do you do about ModelView files growing massive in a MVVM application?

I am writing a MVVM application and one of the screens is quite significant in size. The screen maintains and object that has multiple lists of other objects that also get editied within the context of the transaction. I've broken the views up into multiple user controls. The model is broken up into the different class types. The proble...

Learning MVVM for WPF

I am now very comfortable with WPF, but I read some articles about MVP and MVVM that find the default project solution ineffective. Then I realized how ineffective it was and how the MVVM pattern is much better. So I want to really learn this pattern. Can I be directed to some resources like maybe a tutorial or a video or something? ...

MVVM visual studio project template for VS2010?

I am running VS2010 and Windows 7. I have seen many people with the template for MVVM. Where can I get this template? I already have WPFToolkit installed, but the template does not appear. I tried to go to the sites, like codeplex, that say they have it and it turns out to be the WPFToolkit installer. ...

MouseBinding the mousewheel to zoom in WPF and MVVM

OK, I've figured out how to get my Grid of UI elements to zoom, by using LayoutTransform and ScaleTransform. What I don't understand is how I can get my View to respond to CTRL+MouseWheelUp\Down to do it, and how to fit the code into the MVVM pattern. My first idea was to store the ZoomFactor as a property, and bind to a command to adj...

Does 1 ViewModel really have 1 View?

Hello, its said that 1 ViewModel has 1 View. 1 View is for me a UserControl. What if my UserControl has different areas filled with data from different entities, do I have then several Views and need to build several ViewModels? e.g: I display in a UserControl 3 entities: customer(listbox),order(datagrid),product(datagrid). Each of th...

viewModel vs model who has responsability to communicate with business layer?

Hi, New to wpf and MVVM .I am kind of confused what belongs to what. Lets suppose we have a view with a btnSave. When saving who's the responsability to call the Business Layer ? My understanding is that Model is just holding properties and no methods ViewModel is actually implementing EG " DelegateCommand SaveCommand and therefore c...

wpf mvvm .. access view elements in viewmodel

I am in phase of learning wpf/mvvm as per i get to know in vm we declare commands and bind them to view element's event rather doing this in codebehind file... what i am not getting is, how would we access view elements and eventarguments. ...

Can a ViewModel talk to View in MVVM pattern?

Hello, In MVP pattern, a Presenter has an interface of View so the presenter can call iview.DoSomething().. What about in MVVM pattern? According to John Gossman's UML diagram http://blogs.msdn.com/johngossman/archive/2006/04/13/576163.aspx , ViewModel doesn't have an interface of View. So, seems like the ViewModel and View should be ...

Hook in datatemplate view switch/change

Hello, I am switching my UserControls via DataTemplate. When I leave the UserControl/DataTemplate View I need to ask wether the user wants to save or not because else all data will be lost like graphical location points x,y of a user drag/dropped Rectangle on a canvas. How can I hook into the datatemplate change and bring up my own sav...

MVVM Clarification: What belongs into ViewModel, what belongs into Model?

So I was looking into MVVM again after some time where I didn't really follow new developments and I noticed that the amount of tutorials/guides etc. has grown greatly. However most examples/example implementations of MVVM lack to explain something that's not really clear to me. All of these examples are pretty simple and none of them re...

MVVM: Binding radio buttons to a view model?

I have been trying to bind a group of radio buttons to a view model using the IsChecked button. After reviewing other posts, it appears that the IsChecked property simply doesn't work. I have put together a short demo that reproduces the problem, which I have included below. Here is my question: Is there a straightforward and reliable w...