mvvm

How do I databind to a ViewModel in Expression Blend?

In WPF and Silverlight you can make a view model object and set it into the DataContext of a control when the control is constructed at runtime. You can then bind properties of the visual object to properties in your DataContext. One way to set the binding is to type the binding directly into the tag: <TextBox Text="{Binding Path=Desc...

How to activate new page on some event in MVVM-WPF?

Hi, I have a list page which list records in graphical representation. On clicking a some graphical portion or some button-which is added runtime on page- i want to activate new page by passing a some data as a parameter. Eg. I have Category list page, the UI representation is done at runtime. So clicking on some category I want to lis...

What is your experience with abandoning MVVM for UserControl-based WPF architecture?

We built an large application based on Composite Application Library and MVVM using Infragistics controls. In order to save time and make the application more straight-forward, we scrapped the MVVM requirement. We now have no Presenters or ViewModels and our Views have become simple UserControls which are created like this: BaseEditor....

What is the best option to bind/edit data using DXGrid from MVVM pattern?

I'm trying to bind DXGrid control to an IList. Though binding works perfectly fine some other features of the grid are not working like those of Auto filter row, and In-line editing. <dxg:GridControl x:Name="grid" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" DataSource="{Binding Path=Model, UpdateSourceTrigger=PropertyChang...

GlobalSettings ViewModel

I have some global settings that should come from the ViewModel and should be available to all DataTemplates across all UserControls. It includes things like GlobalButtonMargin, GlobalStrokeWidth or GlobalWorkspaceBackgroundColor. Those things are in the viewmodel because the user can edit these settings at runtime. How would you go ab...

Need a good way to manage the status - was the data changed since last save - under MVVM

Consider an application which is implemented using MVVM, in which the user inputs data. When the user selects "open file", "new file" etc., the application asks the user if he wants to save the data to a file before invoking the requested command. However, if the user did not change any data since the last save, the application should sk...

What makes MVVM uniquely suited to WPF?

The Model-View-ViewModel is very popular with WPF and Silverlight. I've been using this for my most recent projects, and am a very large fan. I understand that it's a refinement of MVP. However, I am wondering exactly what unique characteristics of WPF (and Silverlight) allow MVVM to work, and prevent (or at least make difficult) this...

Modules, Views, Menus, Ribbon

I am mulling over various ways to provide both navigation and general functionality in a WPF/MVVM/Unity application (the app is effectively database front-end, with usual record editing, reports, etc). I have an expander-type vertical bar to select views which is fine. But, I now feel I need a toolbar (perhaps ribbon style) to be visibl...

Castle Windsor (or other DI) - creating object based on parameter

Hi there! I am pretty new to the whole DI/IoC thing, so bear with me... I have this kind of setting: interface IA interface IB interface IC abstract class A : IA class B : A, IB class C : A, IC interface IX interface IY interface IZ abstract class X : IX class Y : X, IY class Z : X, IZ B and C's constructors look like this: public...

MVVM - How can I programmatically select a view for my viewmodel?

How can I select a view for my viewmodel without using code behind? I want to load a ListBox with a lot of data coming from a WCF call. Using Josh Smith's app, the view loads before the data arrives, empty. I want to receive all the data and then select the view with spinner showing progress. // Completed Method void _background...

Redirection Between View In MVVM

I am using MVVM patern for developing my WPF application. It working fine for unrelated pages, means how to go in another view from one view. Eg: I have one list page in which some records are coming from one ViewModel and another from another ViewModel, means I have two ViewModel form my single View. And now I want to display another ...

MVVM, REST and AsyncModels

Hi! I feel, that MVVM and REST being considered together can produce a solid and reliable pattern for programming for many years. (My intuition says me that we SHOULD consider them together). Also it seems that it should be a proper abstraction for Asynchronous operations in ViewModels and Controllers - like a composable asynchronous dat...

why does my ObservableCollection-bound control jump to 1st item?

I have a TDI, bound to an observable collection of workspaces (all based on Josh Smith's MVVM Demo). On one tab, there is a user control, also bound to an observable collection. If I switch tabs, the user control always jumps back to the 1st item. I'm kinda desperate. I searched since 5 hours now but just I can't figure out why it does...

WPF Toolkit calendar control in a MVVM solution, how to highlight days?

From this article http://msdn.microsoft.com/en-us/magazine/dd882520.aspx I wanted to create a list of selected days like he did. Except my list is not static and putting it in the converter seems smelly. Has anyone done something similar with the WPF toolkit calendar control? Or are we trying to use this control for something more tha...

A good aproach to events in MVVM

So I ran into this problem trying to implement MVVM. AFAIK the best way to execute a method in the ViewModel class is through a CommandBinding. <Button Command={Binding DoSomethingCommand} /> Only this time I need to do something on a ListBoxItem double click, and the ListBoxItem doesn't implement ICommandSource. So I'm wondering what...

Handle exceptions with WPF and MVVM

I am attempting to build an application using WPF and the MVVM pattern. I have my Views being populated from my ViewModel purely through databinding. I want to have a central place to handle all exceptions which occur in my application so I can notify the user and log the error appropriately. I know about Dispatcher.UnhandledExcepti...

WPF Commands - Doing it with no code-behind

I'm building a simple data entry app in WPF form using the MVVM pattern. Each form has a presenter object that exposes all the data etc. I'd like to use WPF Commands for enabling and disabling Edit/Save/Delete buttons and menu options. My problem is that this approach seems to require me to add lots of code to the code-behind. I'm tryin...

WPF Data binding issue using mvvm pattern

I have created a user control "SearchControl"(which will be reused further in other screens as well. SearchControl -> <usercontrol name="SearchControl"......> <stackpanel orientation="horizontal"...> <TextBox Text"{Binding Path=UserId}"...> <Button Content="_Search" ....Command="{Binding Path=SearchCommand}"..> </...

How to resolve bound object from bindingexpression with WPF?

Hi does anyone know if there are any inbuilt classes for resolving a bound object from a bindingexpression and it's DataItem and property path? I'm attempting to write a Blend 3 behavior for textboxes which automatically invokes methods on an object bound to the textbox Text property. The textbox is bound to a property on a viewmodel c...

wpf multibinding to viewmodel??

For the life of me, I can't seem to bind to my viewmodel using multibindings. All of the examples on the net bind to gui elements directly, but whenever I try with a viewmodel object exceptions are thrown. My question is, how do I add a multibinding to several viewmodel objects in xaml? I need to bind the IsEnabled property of a contex...