Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
260
xamContextMenu and MVVM on a XamDataTree
posted

I am using a SL XamDataTree and wish to bind a context menu to a command in my ViewModel (MVVM).

The tree is defined as follows:

<ig:XamDataTree  x:Name="xamTree"
                                         AllowDrop="True"
                                        IsDropTarget="True"
                                         AllowDragDropCopy="False"
                                        Grid.Row="0"
                                        ItemsSource="{Binding RootFolderContactsNode.SubItemsSorted}" 
                                        MaxHeight="550"
                                        NodeDragDrop="xamTree_NodeDragDrop"
                                        Background="Transparent">
                            <ig:XamDataTree.GlobalNodeLayouts>
                                <ig:NodeLayout x:Name="NL" 
                                               Key="SubItemsSorted"
                                               DisplayMemberPath="Name"
                                               TargetTypeName="FolderContactTreeNode"
                                               IsDraggable="True"
                                               IsDropTarget="True">
                                    <ig:NodeLayout.ItemTemplate>
                                        <DataTemplate>
                                            <StackPanel>
                                               <ig:ContextMenuService.Manager>
                                                    <ig:ContextMenuManager OpenMode="None">
                                                        <ig:ContextMenuManager.ContextMenu>
                                                            <ig:XamContextMenu Name="cmuFolder"
                                                                               >
                                                                <ig:XamMenuItem Header="Edit">
                                                                    <ig:Commanding.Command>
                                                                        
                                                                        <ig:XamContextMenuCommandSource EventName="Click" 
                                                                                                        Command="{Binding DataContext.CommandEditFolderOrContact, ElementName=LayoutRoot}"
                                                                                                        Parameter="{Binding}"/>
                                                                    </ig:Commanding.Command>                                                                  
                                                                </ig:XamMenuItem>
 
 
                                                            </ig:XamContextMenu>
                                                        </ig:ContextMenuManager.ContextMenu>
                                                    </ig:ContextMenuManager>
                                                </ig:ContextMenuService.Manager>
                                               
                                                <StackPanel Orientation="Horizontal">
                                                    <Image Source="{Binding Data.Image}" Width="12" Height="12"/>
                                                    <TextBlock Text="{Binding Data.Name}" Margin="2.5,0,0,0"/>
                                                </StackPanel>
                                            </StackPanel>
                                        </DataTemplate>
                                    </ig:NodeLayout.ItemTemplate>
 
                                </ig:NodeLayout>
                            </ig:XamDataTree.GlobalNodeLayouts>
                        </ig:XamDataTree>

I keep getting an unhandled exception because of the Command parameter in the <ig:XamContextMenuCommandSource/> element.  'Command' does not show up in intellisense, but is in the documentation (http://help.infragistics.com/Help/NetAdvantage/Silverlight/2012.1/CLR4.0/html/InfragisticsSL5.Controls.Menus.XamMenu.v12.1~Infragistics.Controls.Menus.XamContextMenuCommandSource_members.html). Any help in how to use Commanding correctly on a ContextMenu in a xamDataTree would be appreciated.

Thank you,

Bill

Parents Reply Children
No Data