.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Where do Enums fit into the MVVM pattern?

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :JQuery

Which layer would Enums be part of? The data objects (Model) might need an Enum for some property, and the View may need to bind to the ViewModel using the same Enum with a ValueConverter. For example, a series of CheckBoxes that are each a separate bit value of an Enum or a series of RadioButtons based on an Enum. The View would bind to the ViewModel using that Enum and a ValueConverter.

The View is not supposed to have knowledge of the Model and the Model should not have knowledge of the View or the ViewModel. So, what part does the Enum belong to?

Or should the Model contain the integer value of the enum and be converted to the actual Enum in the ViewModel? Then the Enum would just be in the ViewModel...

View Complete Post

More Related Resource Links

WPF MVVM pattern Projects

Hello,   I'm planning to develop WPF,C# using MVVM pattern.I'm looking for Sample projects using MVVM style i.e, like we have on Asp.net Web MVC NerdDinner,MVC MusicStore,Microsoft TownHall project.Can i find similar or any other help ful links for MVVM projects?    

Problem in tab control with MVVM Pattern

Hi,  Am new to wpfpatter and mvvm also. I have problem, i need to assign the same shortcut key(say alt+N) to two button in different tab. i have used the following code to assign the shortcut. problem in when i click the shortcut key in tab one it will get trigger the tab two button event. --xmal code is     <UserControl.InputBindings>         <KeyBinding Command="{Binding Path=Delete1Command}" Modifiers="Alt" Key="N"></KeyBinding>         <KeyBinding Command="{Binding Path=Delete2Command}"   Modifiers="Alt" Key="N"></KeyBinding>     </UserControl.InputBindings>        <TabControl  Height="100" HorizontalAlignment="Left"  Name="tabControl1" VerticalAlignment="Top" Width="200">             <TabItem Header="tabItem1" Name="tabItem1">                 <Grid>                     <Button Content="Button1" Height="23&q

combobox in datagrid with MVVM Pattern



  i have requirement that, datagrid has a two column one is text column and other is combo box, combo box contain 2 column including checkbox. once i click the checkbox in combobox, resepective first column value need to display in combo box selected item and second column values need to display in first column of the data grid.

  I have used following code in xmal


<DataGrid x:Name="dgMixture"  VerticalAlignment="Top"  Width="250"
                      RowHeight="25"  GridLinesVisibility="Vertical" HeadersVisibility="Column" IsReadOnly="True"  AutoGenerateColumns="False"
                      HorizontalAlignment="Left" CanUserAddRows="False" ItemsSource="{Binding CompanyItemsCV}"   >

Extending the expander control - MVVM pattern


Hi all,


I am using MVVM and need to create an expander that also has a "close" button, making it disappear.

I thought about creating a UserControl containing an Expander + Button with "close" caption.

Then, expose a Command property for that button click, handling it in the ViewModel.

Problem is, I have to expose many other Expander related properties as well (content, IsExpanded, IsEnabled etc...)

Is there any other idea for this issue?


Thanks a lot!

How to bind wpfdatagrid with collection of collection in MVVM pattern?


Hi everyone,

I am using MVVM pattern. I have some dynamic data and i want to bind it with datagrid. I converted my data in a collection which also contain anaother collection in following way.

First i create a class in my Model,which has some properties like this

namespace DummyDataGridBindingApplication.Models
   public class EntityAttribute
        public string AttributeName
        public string AttributeValue
        public string AttributDataType 

WPF, MVVM , Entity Framework: Is there an example to show how Entity Frameowk work with MVVM pattern


Is there an example to show how Entity Frameowk work with MVVM pattern or WPF?
Does it suppose to be the Model layer implement LINQ to Entities?

Use of InkCanvas cantrol in MVVM pattern to save image


Hi All,

Can any one tell me how to use "InkCanvas" control in MVVM pattern.

I am able to save image using Code Behind in a Button click event.

But i am not getting any solution to save image using MVVM pattern binding a property to InkCanvas control.

Please help guys

Thanks and Regards



Dialogs and ViewModel - Using Tasks as a Pattern

The ViewModel/MVVM pattern continues to gain popularity, with a blog post showing up every so often, and with tweets and retweets popping up even more often :-). At the same time, there are some interesting topics beyond the core pattern that continue to fuel experimentation. A big one amongst those is how should applications use dialogs when using the view model pattern.

The crux of the problem is the desire to keep the view model independent of UI concerns, and ensure it can be tested in a standalone manner, but that often comes to odds when you want the view model to launch a dialog, and/or do some work after the dialog is closed.

WPF: If Heineken did MVVM Frameworks Part 4

MVVM is to have an instance of a particular Model (say currentPerson) inside my ViewModel (say PeopleViewModel) which is exposed to the View (say PeopleView). The View binds and edits the Model directly.

This definitely flies in the face of what most people consider to be the holy grail of MVVM pattern, but it's a fairly new pattern, so people are still finding their way with it every day, and this works for me very well. The reason I do what I do, is for the following reasons:

1.I have always had the luxury of being able to write my own UI specific Model classes. I would even do this if I was using some other Model classes first, such as LINQ to SQL or LINQ to Entity Framework. As these classes don't have everything a proper WPF Model class needs in my humble opinion. Though, they are pretty good, as they are Partial classes and use INotifyPropertyChanged/DataContract etc etc
2.I am a pragmatist and I do not like writing code for the sake of writing code. I have seen some MVVM apps where the author has had a Model with 50 properties on it, that are simply repeated in the ViewModel abstraction, where the ViewModel added nothing. On that day I decided I would never do that unless I have to.
3.I honestly see no harm in writing directly to the Model from the View, JUST SO LONG AS if the Model is InValid its data NEVER makes its way to the database. I honestly see no pro

Prototype Design Pattern in C#. Vb.NET

Specify the kind of objects to create using a prototypical instance, and create new objects by copying this prototype

Adapter Design Pattern in C#, VB.NET

Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.

Singleton Design Pattern in C#, Vb.NET

Ensure a class has only one instance and provide a global point of access to it.

The Decorator Pattern & Extension Methods

The decorator pattern provides a formal way to add new functionality to an existing type, without sub-classing. First question: What is wrong with classical inheritance? In and of itself, nothing is wrong with the good old Is-A relationship. It is very common to derive a new class from an existing base class in order to override a few virtual members, and add a pinch of new functionality.

Implementing Continuous Scrolling UI Pattern in ASP.NET

When you have numerous records to show, we have to resort to Paging. There is a better alternative to display voluminous data (especially read only data) while providing a better user experience & also making efficient use of server bandwidth - the Continuous Scrolling or Infinite Scrolling UI Pattern. Read on to know more about how to implement Continuous Scrolling UI Pattern in ASP.NET with a GridView.

Factory Pattern in asp.net

The job of the Factory design pattern is to create concrete sub classes. You can see the Factory design pattern used throughout the .NET Framework.

The essence of the Factory Pattern is to "Define an interface for creating an object, but let the subclasses decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses." Factory methods encapsulate the creation of objects. This can be useful if the creation process is very complex, for example if it depends on settings in configuration files or on user input.

Singleton Design Pattern in Asp.net using C#

When we want to make a only one instance of a class and also making sure that there is a global access point to that object then the design pattern we user is called Singleton. The pattern ensures that the class is instantiated only once and that all requests are directed to that one and only object.

The Factory Design Pattern

Software architects generally think in terms of high-level abstractions rather than low-level programming details. Representing a system in terms of high-level abstractions promotes understanding of the system and reduces its perceived complexity. One such set of abstractions is software design patterns. They have been successfully applied in the past to simplify and solve recurring problems in software design.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend