mvvm

MVVM pattern for ASP.NET Webforms ?

Hi, I'm looking for an MVVM implementation for ASP.NET. How should I approach this ? Can you propose any design that solves this problem particularly for ASP.NET Webforms ? Thanks. ...

How to get a WPF Toolbar to bind to a collection in my VM without using expander

I have a WPF window that has a toolbar. I have a collection of objects in my VM that I'm binding to. They appear as buttons but they always get pushed to the expanded drop down part of the toolbar. How do I make those buttons appear in the standard part of the toolbar? I have the following XAML: <ToolBarTray Grid.Row="1"> <T...

lazy loaded NHibernate collections into ViewModels?

hey folks, I have my NHibernate mappings set to lazy loading = true. In my CustomersViewModel I have something like: foreach (Customer c in _customerRepository) { this.Customers.Add(new SingleCustomerViewModel(c)); } This obviously kills all the lazy loading, since the customers are passed one by o...

User Control Data Binding in Silverlight/MVVM.

Do DependencyPropertys default to two way binding? If not how do you specify? The reason I ask is that I have the following user control which is causing me problems... <UserControl x:Class="SilverlightApplication.UserControls.FormItem_TextBox" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas....

ComboBox with IEnumerable<Brush> as ItemsSource and SelectedItem exception

Hi all, I have this issue with ComboBox that uses IEnumerable<Brush> as ItemsSource; the problem lies when I (programmatically) try to set SelectedItem. Here is the code that describes the problem: private readonly List<Brush> colors_; private Brush white_; ViewModelConstructor() { colors_ = (from p in brushes_type.GetProperties()...

Problem with text input in textbox control

I'm working in a WPF project, which basically is a class library project that implements the MVVM pattern. For clarity purposes I'm gonna say that I just have a single window with a single textbox control on it. Now, I'm adding this dll to another project, which is a Windows Forms project, and I'm calling the window with the textbox co...

If it is technology specific, is it still a design pattern?

I went to a .NET user group meeting tonight, and part of it revolved around the model-view-view model pattern, and it got me wondering if this qualified as a pattern. The issue I have is that M-V-VM is extremely technology specific. If you do not use WPF and its binding mechanism, I don't see how you could use that pattern. By contrast, ...

How have you combined the advantages of the direct View-to-Model approach and MVVM in your WPF projects?

In our application we have many Model objects that have hundreds of properties. For every property on the model: public string SubscriptionKind { get; set; } ...100x... we had to make an INotifyPropertyChanged-enabled property on the ViewModel: #region ViewModelProperty: SubscriptionKind private int _subscriptionKind; public int Sub...

Navigation in MVVM based application

we are designing a xbap application that has complex, user configurable navigation flow that depend on state of the model\user security etc and some other environmental factors. The application is having a container view that loads user specific controls inside a Frame, i am wondering whats the preferred practice for having the navigati...

ViewModel tree vs. frequently updating Model tree

In my WPF MVVM application my model is a complex tree of Model objects wich constantly changes at runtime. Model instances come and go at runtime, change their position within the tree and of course change their many properties. My View is almost a one-to-one visual representation of that tree. Every Model instance is in 80% of the cases...

WPF OpenFileDialog with the MVVM pattern?

I just started learning the MVVM pattern for WPF. I hit a wall: what do you do when you need to show an OpenFileDialog? Here's an example UI I'm trying to use it on: When the browse button is clicked, an OpenFileDialog should be shown. When the user selects a file from the OpenFileDialog, the file path should be displayed in the text...

.NET delegate equality?

I think this is the question, anyway. I am using a RelayCommand, which decorates an ICommand with two delegates. One is Predicate for the _canExecute and the other is Action for the _execute method. ---Background motivation -- The motivation has to do with unit testing ViewModels for a WPF presentation. A frequent pattern is that I hav...

WPF and MVVM: Changing data binding converter at runtime

I am using WPF and the MVVM pattern in my user interface. In my ViewModel I have a List containing distances in millimetres, which I display in a ListView by binding ListView.ItemsSource to the List. However, I would like the values displayed to use a more natural unit - either metres or feet depending on the state of a "metric" checkbox...

Why MVVM and what are it's core benefits?

Why we go for MVVM over MVC or MVP while dealing with WPF? What extra benefit we get by using this? Edit: To be honest , today I had an interview and I have been asked this question. I answered like INotifyPropertyChanged , ICommand,IValue Convertor.. but he was not satisfied. Henceforth I have put up this question Thanks in advance...

WPF MVVM Property Change Animation

I am looking for a clean way to start an animation that will have dynamic values. Basically I want to do an animation where an element changes width based on the data of another element. Say I have a TextBlock that's Text Property is Binding. When this property changes I want a visual element say a Rectangle for our sake to do a Doubl...

Binding to a collection of shapes?

How would I bind to a collection of shapes? I'd like to build a small application (just for learning purposes) where I utilize MVVM for drawing shapes. The DataContext of the MainWindow is the MainWindowViewModel That MainWindowViewModel has an ObservableCollection of shapes. I have currently only a Canvas on my MainWindow with it...

Good examples of MVVM Template

I am currently working with the Microsoft MVVM template and find the lack of detailed examples frustrating. The included ContactBook example shows very little Command handling and the only other example I've found is from an MSDN Magazine article where the concepts are similar but uses a slightly different approach and still lack in any...

MVVM Command Routing Between Controls

I currently have a main View with a Button and a ContentPresenter which is bound to a property of the ViewModel which is another View (and associated ViewModel). Is there way to route a command from the a handler declared in the control loaded in the ContentPresenter? My reason for this is the main View contains the tool bar and the co...

Can I declaratively bind an ItemsContol.ItemsSource to an ObservableCollection in Silverlight?

I can't for the life of me figure out why this doesn't work. I've got a simplified piece of Xaml that looks like this: <UserControl x:Class="Foo.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://sc...

MVVM Mediator multiple instances

Can someone explain how the mediator pattern works with multiple instances. My code in the view: public MyView() { Mediator.Register("CloseWindow",()=>Close()); } and in the ViewModel: public SomeMethod() { Mediator.Notify("CloseWindow"); } This works find as long as there is only one instance of the View - ViewModel pair....