mvvm

Issue with MVVM view first approach.

Hi, I am using mvvm architecture view first approach in my project. I mean I have view-viewmodel binding defined in resource file. But i'm unable to open multiple instances of same view...If I open the the new viewmodel will refer to the first view. ...

Question about MVVM Tutorial: Closing Workspaces/Observable Collection

this is in regards to the tutorial on msdn. This is whats used to close workspaces or tabs. // workspaces declared as follows _workspaces = new ObservableCollection<WorkspaceViewModel>(); _workspaces.CollectionChanged += this.OnWorkspacesChanged; void OnWorkspacesChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.N...

How do I write a unit test for this method in my view model in Silverlight without SecurityException?

I have a Silverlight testing project using the Silverlight Unit Test Framework. I want to test a method in my view model which takes FileInfo objects. This seems to work fine when I test it manually through the UI. Now I want a unit test just for the AddDocument method. I don't want to test actually clicking the button or simulate cl...

Good or bad practise for Dialogs in wpf with MVVM?

hi, i lately had the problem of creating add and edit dialogs for my wpf app. all i want to do in my code was something like this. (I mostly use viewmodel first approach with mvvm) ViewModel which calls a dialog window: var result = this.uiDialogService.ShowDialog("Dialogwindow title goes here", dialogwindowVM); ... do anything with...

MVVM window/region handling

Two questions here. My view has a "close" button that when clicked, the window should close. I handled this as follows: The button in my view binds to a command defined in the view's view model, which when triggered runs the following: private void Exit() { var regionManager = Container.Resolve<IRegionManager>(); M...

OnPropertyChanged with a List

I have a data grid in a view that is bound to a List in a viewmodel. I have a lot of data to retrieve for the list, so I want to break it up into many small retrievals instead of one big one. I want this to happen on a background thread with the UI updating (the grid binding the new data) at the end of each batch retrieved. At the end...

MVVM WPF save and load user settings design pattern

I am looking for a good tutorial / explanation that shows where and how to implement settings in a MVVM WPF application. I understand .net has built-in support for settings but is this typically used for medium to larger size applications? What are the alternatives? I am thinking of storing many user settings such as window size, grid...

Communication between ViewModels

Hi! I have two questions regarding communication between ViewModels. I am developing a customer management program. I'm using Laurent Bugnion's MVVM Light framework. In the main page, there's a list of customers. when each customer is clicked, a child windows shows up with information about that customer. the user should be able to o...

WPF/C# Forwarding events and DataProvider values within a UserControl

I have a UserControl which contains 4 ToggleButtons and I'd like to trigger a custom event that an interested object can listen for which provides a status, based on the ToggleButton Checked values and also value(s) from the DataContext object. Getting the ToggleButton checked values and deriving a status is simple enough, however I can...

Is there any data binding support for MonoTouch?

I am thinking about how an application can be written to work on both Windows 7 Phone and IPhone, one option is to use MonoTouch and structure the app with MVVM, then only the views will need to be different between the platforms. However MonoTouch does not seem to support data binding. When (if) data binding support is added to Mon...

Dynamically create elements and bind them to a List<T>

I have a ObservableCollection<Class1> where Class1 contains x and y positions as properties. The list can be of any size. I have a ViewModel that exposes the collection as a property. In my view, I want to generate a list of elements based on the collection and then set their x and y positions based on the Class1 Object's properties. Ho...

Large Model Collections in MVVM

Hi everyone, Whilst implementing my first MVVM application in WPF, I've been wondering about the pros and cons of wrapping Model collections in related ViewModel collections to use in the View. In our system we are likely to have several potentially large collections e.g. Order Lines in an Order, and Stock Items which could be selected...

How to avoid waiting for Silverlight templated control initialisation in context of MVVM

I'm trying to make and use templated controls in an application but I seem to run into timing isssues. When I use a custom templated control, in XAML <local:MyControl> and through code (new MyControl()), and call a method on the control that tries to do something with a control in the Controltemplate, a control in the template is almost ...

MVVM with LinqToSQL

Hello Together, there a little BrainF*** question for me to understand MVVM in relation to LinqToSQL. The MVVM is build like: View --> Viewmodel --> Model View: the xaml and the cs code behind file. right ? Viewmodel: created by the Developer (*.cs), encapsulated properties of my Model Model: Datamodel So here is the Question: ...

wpf - HierarchicalDataTemplate, VirtualizingStackPanel, Window Resize (maximize)

Hi, I am having a problem with a wpf treeview that uses a HierarchicalDataTemplate in conjunction with a VirtualizingStackPanel. Using the code provided below, I run the application and expand all the treeviewitems. http://img227.imageshack.us/img227/3536/wpftv03.png I then make the viewport "small" so that items are virtualized. ...

WPF MVVM ItemsControl with Multiple ViewModels depending on the object type

I have a collection that holds multiple types of items that all inherit from the same interface. This is bound to an ItemsControl. The DataContext of the window is set to the ViewModel that holds the collection. What I would like to do is have each item of a different type in the collection use a different ViewModel. So if my template...

Problem with Data Binding ViewModel

I have a ViewModel class FontsViewModel : ObservableObject { public FontsViewModel() { InitFonts(); } public ObservableCollection<Typeface> Fonts { get; private set; } protected void InitFonts() { Fonts = (ObservableCollection<Typeface>)System.Windows.Media.Fonts.SystemFo...

Passing a Parameter to ViewModel constructor

Is it possible to pass a parameter to the ViewModel constructor? I would then use this parameter to initialise a property and/or do other operations in the ViewModel. With WinForms I could do public MyForm(MyParamType myParam) { MyFormProperty = myParam; //etc. } How do I go about doing something similar in the MVVM pattern ...

Widget development for wpf

Hi, I am searching for a design pattern, open source platform or what can else use to develop widget for wpf applications. I need to develop a host application that could load predefined or custom widget and this widget could interact with host application or could communicate with other widgets. User could add new widget without quiting...

Update ListView when properties of items change

Hi. I want to implement a panel to set user permissions. So i have a PermissionListView where the ItemSource is an ObservableCollection and in this PermissionListView I have a Checkbox for each Item which is bound to PermissionViewModel.Checked. I debugged it and this works. The user gets selected in another ListView(UserListView). But ...