mvvm

Learning WPF and MVVM

Hi folks I have recently joined a new developing project building a thick client application using WPF and MVVM. I have developed applications in various .NET frameworks from 1.1 through to 3.5 and all major technologies; WebForms, MVC and WinForms. On all of my projects I have enjoyed every minute of it but on this project I feel that ...

Adding an item to an ObservableCollection of an unknown type

I'm creating a WPF application using the MVVM design pattern, and I'm trying to create a Combobox that allows the user to edit the items in the drop-down list at runtime, similar to the way MS Access 2007 lets you do it. So I've created a UserControl that builds on top of a Combobox... when the drop-down is shown, there is a button belo...

Resources for implementing MVVM (ViewModel) pattern in Flex?

Can anyone direct me towards some code or a tutorial for implementing the ViewModel in Flex 3? All I'm finding on the web are examples for Silverlight. ...

Combo box styling to show rating and description WPF

Hi all, I'm not very good with styling in WPF, so I thought that I would ask here and see if anyone can help. I have a combo box which is bound to a view model that has a rating and description, when I hover my mouse over a item the item changes to show the rating and description for that item. This works ok however because some of th...

MVVM CollectionViews in WPF Application Framework (WAF)

In short my question is: How do you prefer to expose filtered/sorted/grouped ObservableCollections to Views in WAF? I was fairly happy with my first attempt which involved filtering on the VM and exposing an ICollectionView of Model objects for the View to bind to: public StartDetailViewModel(IStartDetailView view, StartPoint start, Sc...

Intermittent Command CanExecute Firing

Hi, I hope someone can help me with this one... Unfortunately to put all the code in is just not feasible, however.. I am implementing the MVVM pattern, I have a content presenter that displays a UserControl. The UserControl has a number of items on it with some basic CRUD functions, e.g. Edit, Delete, etc. I have set up the Control, ...

Binding an IList to list control using MVVM

I am trying to understand MVVM pattern and I took a sample program to work on. The model is a C# .net library which when queried returns an IList object. I want my view to be able to add/edit/delete items in this collection thru' data binding. But I don't know how to start with this, using MVVM. Please help me out. Model exposes an inte...

WPF datagrid allow user to add rows?

I would like my WPF Datagrid that is bound to my observable collection to have the blank row at the bottom so that the user can add more info. I've successfully bound the data, i.e. I can see it. Why is the 'new' blank row not showing? Here is my xaml declaration: <UserControl.Resources> <CollectionViewSource x:Key="MyItems" Source="...

Final steps in using MVVM to decouple GUI from business logic?

Just recently, I learned about using MVVM to decouple GUIs from the underlying model. I ended up learning as much as I could to convert my current application over to MVVM, and was largely successful. Now I need to figure out how to actually take a GUI generated in Blend and use it in place of my current GUI, which was designed in Visu...

How to fix selected Item in a collection control on a user control (using the MVVM implementation) in WPF

Hi, I hope someone can help me... Josh Smith did a great article on "WPF apps with the Model-View View-Model", and included in his article was the following code sample. If you download the code sample and run the app and view all customers, then select a company (e.g. 4th company), then click "Create new customer" (which will open a t...

Are there any good software development "patterns" for memory intensive .net programs?

Basically I'm working on a program that processes a lot of large video and image files, and I'm struggling with the memory management side of it because I've never dealt with anything quite like this before. For instance, it stores all these images in a database, and loads a list of videos, and then you can switch between the videos an...

WPF Binding IsSelected to ViewModel doesn't set items that haven't been shown in the List

I have a ViewModel that has an IsSelected property which I bind in my ListView.ItemContainerStyle XAML to an IsSelected property in my view model. I bring up the application and populate the view model collection (which is shown in my ListView) with a lot of items, say about 2000. Then I select everything in the list via Ctrl-A. The ite...

What is the correct way to initialize a model and view in WPF CAL MVVM.

I have come accross two ways of initializing Views and ViewModels in WPF CAL MVVM. 1 - Seems to be more popular. Requires you to resolve the ViewModel to automatically resolve the View. The ViewModel contains information about the View. public interface IView { void SetModel(IViewModel model); } public interfac...

Treeview MVVM ObservableCollection Updates

I have a treeview which binds to lots of nested ObservableCollections. Each level of the treeview shows an aggregated sum of all the hours in child items. For example: Department 1, 10hrs ├ Team 10, 5hrs │ ├ Mark, 3hrs │ └ Anthony, 2hrs └ Team 11, 5hrs ├ Jason, 2hrs ├ Gary, 2hrs └ Hadley, 1hrs Department ...

WPF TabControl - how to preserve control state within tab items (MVVM pattern)

I am a newcomer to WPF, attempting to build a project that follows the recommendations of Josh Smith's excellent article describing The Model-View-ViewModel Design Pattern. Using Josh's sample code as a base, I have created a simple application that contains a number of "workspaces", each represented by a tab in a TabControl. In my appl...

Form Validation in WPF

I have been working with WPF and the MVVM pattern for a while now. I'm having difficulty getting validation working in a "normal" way: 1) I'm implement the IDataErrorInfo interface in my ViewModel. The XAML looks something like: <TextBox Grid.Column="1" Grid.Row="1" Text="{Binding Path=ProjectKey, ValidatesOnDataErro...

MVVM Madness: Commands

I like MVVM. I don't love it, but like it. Most of it makes sense. But, I keep reading articles that encourage you to write a lot of code so that you can write XAML and don't have to write any code in the code-behind. Let me give you an example. Recently I wanted to hookup a command in my ViewModel to a ListView MouseDoubleClickEvent. ...

'Generic' ViewModel

Using EF 4, I have several subtypes of a 'Business' entity (customers, suppliers, haulage companies etc). They DO need to be subtypes. I am building a general viewmodel which calls into a service from which a generic repository is accessed. As I have 4 subtypes, it would be good to have a 'generic' viewmodel used for all of these. Probl...

MVVM Pattern - How can I trigger an ICommand or CommandReference in the code behind

Hi... I have been looking for this on Stack Overflow, but couldnt find an answer to this yet so I hope this isnt a duplicate... I have an app using the MVVM pattern, I like to keep things clean, but sometimes a little code behind seems cleaner than the XAML workaround. I want to know if it is possible to trigger a command from the code...

WPF MVVM: ICommand Binding to controls

I've totally lost in the command binding that is used in MVVM. How should I bind my object to the window and/or its command to the control to get method called on the button click? Here is a CustomerViewModel class: public class CustomerViewModel : ViewModelBase { RelayCommand _saveCommand; public ICommand SaveCommand {...