locked
ItemsSource, ItemTemplate and ContextMenu snafu RRS feed

  • Question

  • I'm trying to have a Context menu populated through a binding and would like to set command and header through binding.

    I'd like something like this:

    <toolkit:ContextMenuService.ContextMenu>
    	<toolkit:ContextMenu ItemsSource="{Binding ContextMenuItems}" >
    		<toolkit:ContextMenu.ItemTemplate>
    			<DataTemplate>
    				<toolkit:MenuItem Header="{Binding Name}"
    								  Command="{Binding Command}" />
    			</DataTemplate>
    		</toolkit:ContextMenu.ItemTemplate>
    	</toolkit:ContextMenu>
    </toolkit:ContextMenuService.ContextMenu>
    


    It kind of works but the problem is that each MenuItem contains another MenuItem inside it! 

    And I have to click it twice for the ContextMenu to close!

    Any advice would be appreciated!

    Thursday, September 16, 2010 2:03 AM

Answers

  • http://betaforums.silverlight.net/forums/p/199404/469808.aspx

    http://weblogs.asp.net/lduveau/archive/2010/05/31/dynamically-apply-and-change-theme-with-the-silverlight-toolkit.aspx

    http://tuts9.com/questions/25903/silverlight-4-menuitem-looks

    Monday, September 20, 2010 10:05 PM