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

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

Menu item and ViewModel pattern

Posted By:      Posted Date: September 15, 2010    Points: 0   Category :WPF
Dear all, I need to build a ViewModel class for a Menu. For that menu I will have to provide information based on MenuItems collection and also handling the click event. Any advide on how to define my vieModel for that menu ? Thnaks for help regards SergeYour knowledge is enhanced by that of others.

View Complete Post

More Related Resource Links

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.

How to keep the hover for Parent menu and set the selected menu item css for child menu item?



I'm using cssfriendly control adapter for menu. My asp.net menu control's datasource is a sitemap file I'm using which contains all the urls.

I have the following questions:

  1. Is there a way to keep the parent menu item hovered while hovering over the respective child menu items?
  2. Is there a way to keep the child menu item selected? I am able to set the css for the parent menu, however I was wondering if the same is possible with the child items.

Please help! Smile


Moneka Smile

Patterns: WPF Apps With The Model-View-ViewModel Design Pattern


In this article we explain just how simple it can be to build a WPF application the right way using the MVVM Pattern.

Josh Smith

MSDN Magazine February 2009

ASP.NET 4.0 Menu Top Level selected item style


I want to apply a css class to the level 1 menu item (parent) when it or any or it's children are selected.

I've looked at MSDN documentation and any number of examples and walkthroughs but I haven't come up with a way of managing this. I was thinking something like this might work but the style is not being applied to the parent. To further complicate matters, if I try to apply a css style to StaticSelectedStyle it doesn't pick it up at all.

Menu Markup:

<StaticSelectedStyle  Font-Bold="True" ForeColor="#3333CC" />

Code Behind:

        protected void MenuItemClick_NavMenu(Object sender, MenuEventArgs e)


            MenuItem parentItem = e.Item.Parent;

            if (parentItem != null)


                parentItem.Selected = true;



Remove action that appear in the menu which appears when we right click each individual item in libr

i need to remove or hide edit properties menu from  menu which appears when we right click each individual item in library 

Creating a new document in Document Library from custom menu item (in the ECB)

Hello! I created a custom menu item in the ECB for a document library. I'd like for this to create a new document from this menu item. Additionally, I'd like to create a workflow where the Title of the document from which the menu action originates is inserted into a custom textfield in the new document that is created. Is this possible using SharePoint Designer?

Menu Item Spacing

I'm trying to use the menu control for the first time in ASP.NET and everything is fine except for the fact that I can't seem to change the item spacing property. My menu is a horizontal menu where the menu items have come from a sitemap file. I've tried changing the menu item spacing in both the dynamic and state menu item properties but nothing seems to change it. I've also tried changing the item spacing via css but that doesn't work either. Any ideas why this might be?<asp:Menu ID="mnuNavigation" runat="server" DataSourceID="mnuNavigationDataSource" Font-Names="Corbel" Font-Size="16pt" Orientation="Horizontal"> <StaticMenuItemStyle ForeColor="White" /> </asp:Menu> <asp:SiteMapDataSource ID="mnuNavigationDataSource" runat="server" ShowStartingNode="False" />

Passing value from Menu item to my sql

How do I pass the value from my menu item to my sql in the back code? Here's what I have so far. Thank you very much. <div> <asp:Menu id="Menu1" runat="server" BackColor="#CC0000" BorderColor="#CCCCCC" OnMenuItemClick="Menu1_MenuItemClick" BorderStyle="Solid" DynamicHorizontalOffset="2" Font-Bold="True" Font-Names="Tahoma" Font-Size="12pt" ForeColor="White" Height="50px" Orientation="Horizontal" StaticSubMenuIndent="10px" Width="100%"> <StaticMenuStyle BorderColor="White" BorderStyle="Solid" BorderWidth="1px" /> <StaticSelectedStyle BackColor="#FF9900" /> <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" BorderColor="White" BorderStyle="Solid" BorderWidth="3px" /> <DynamicHoverStyle BackColor="#284E98" ForeColor="White" /> <DynamicMenuStyle BackColor="#B5C7DE" /> <DynamicSelectedStyle BackColor="#507CD1" />

Menu selected item formatting problem in mozilla

Hello, I have a problem with menu slected item. when i click on menu item it shold display in different color for that i hv wrote below code in my master page cs file. on page load.  string thispage = this.Page.AppRelativeVirtualPath; int slashpos = thispage.LastIndexOf('/');string pagename = thispage.Substring(slashpos + 1); string pagename = thispage.Substring(slashpos + 1); foreach (MenuItem mi in Menu7.Items) { if (mi.NavigateUrl.Contains(pagename)) mi.Selected = true; break; } this works fine in IE but when i run in firefox my page formatting disturbs means the content page not coming in a proper place. thanx in advance. do the needfull.         

Fully Embracing the Model-View-ViewModel Pattern in WPF

I'm trying to get my head around the M-V-VM pattern as it is used with WPF. So far I have been successful in implementing this pattern but it's perfect (yet). There are a number of common UI workflows that I can't figure out how to implement in this pattern such as:1. A user clicks a button that should show a modal dialog box. Usually the VM has a command on it that the button is bound to and something executes. However, what needs to execute is a UI behavior (opening the dialog box). The VM should not open the dialog box (that would be wrong because the VM now has to know something about the UI). The Window or UserControl or Page inwhich the command was initiated should open the dialog box.2. A user clicks a button that executes a command on a VM. However, this is a long-running command and I'd like to show the WaitCursor during this operation. This is a UI function, not a VM function. Should the VM fire an event? And if so, how does the Xaml handle it?So, M-V-VM experts out there, what am I missing? Help me to see the light...Dave

Cannot access Workflow from List Item menu: "Value does not fall within the expected range."


We are using Sharepoint 2007 sp2.

I am using Sharepoint Designer 2007 to create workflow for some List, suddenly I cannot acess some list items' workflow,and was informed  "Value does not fall within the expected range." , but other items are all ok.

I don't know whether this is concerned with the service pack 2, I installed sp2 yesterday.

Dynamic menu item in MenuItemTemplate (in SPGridView)




I am implementing a SPGridView in a webpart and would like to have dynamic row menus (with different menu items) based on some cell values. It seems that the answer is in the very-poorly documented property HiddenScript of a MenuItemTemplate object, which contains a custom javascript function which should return true if the menu item should be hidden, or false otherwise.


My question is - how do I pass arguments to this custom javascript function? This is how the sample code looks like:


SPMenuField colMenu = new SPMenuField();

colMenu.HeaderText = "Address";

colMenu.TextFields = "url";

colMenu.MenuTemplateId = "PresenterListMenu";

colMenu.NavigateUrlFields = "url";

colMenu.NavigateUrlFormat = "{0}";

problem with viewmodel pattern


 This are my controllers:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;


problem with viewmodel pattern


Hi. I've been studying the book Professional ASP.NET MVC 2 and I've tried to implement the technical "ViewModel Pattern" to pass data from the controller to the view. I built the DinnerFormViewModel Class and changed the inherits attribute to Inherits="System.Web.Mvc.ViewPage<NerdDinner.Controllers.DinnerFormViewModel> (into the edit view) but when I modify some DINNER data, the information is not updated. Why happen this? Can you help me?

How to remove 'Delete Item' from context menu of a programmatically created list?

How to remove 'Delete Item' from context menu of a programmatically created list?
I have document library which is created programmatically but now I don't want to have 'Delete Item' in context menu of that document library. Are there any possibilites?

List Item menu button not lined up when scrolling

I have a custom master page and when I am viewing a list that requires me to scroll, the list item menu button doesn't display on the line I am currently hovering over. Instead it displays a few lines up, depending on how far I have scrolled. Any ideas on how to fix this?

menu item opens from below the menu and not to the right



when writing a menu in WPF, the menu acts differently between the main menu is pressed, and when one if it's dependencies when pressed.

on the first level, it opens the items from below the menuitem the was pressed.

in the second level it opens it from the right of the menuitem that was pressed.

i want that in all levels it will open the next submenu from the right of the menuitem that was pressed.

does anyone have an idea how ?

thanks !

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