I have a GridView with a HierarchyChildTemplate that has a Grid View. I need a context menu in that ChildTemplate GridView that sees things on the View Model. How do I get it to see the viewmodel for the proper binding?
Code:
The context menu in the parent grid is fine, but the one in the nested grid is not right.
Side question. Is there a better way to do the nested grid thing than the HierachyTemplate? I would like for this to be one grid that does nesting. I tried using ChildTableDefinitions, but I can't specify things like columns and what not.
Thanks,
Greg
Code:
<telerik:RadGridView Grid.Row="0" x:Name="radGridView" ItemsSource="{Binding Items}" AutoGenerateColumns="False" SelectionMode="Extended" SelectionUnit="FullRow" ShowGroupPanel="False" Margin="25,25,25,25" ui:MultiSelectorBehaviours.SynchronizedSelectedItems="{Binding Path=SelectedItems}" AllowDrop="True" IsFilteringAllowed="True"> <telerik:RadGridView.ChildTableDefinitions> <telerik:GridViewTableDefinition/> </telerik:RadGridView.ChildTableDefinitions> <telerik:RadGridView.HierarchyChildTemplate> <DataTemplate> <telerik:RadGridView ItemsSource="{Binding ProjectionTasksLink}" AutoGenerateColumns="False" SelectionMode="Extended" SelectionUnit="FullRow" ShowGroupPanel="False" AllowDrop="True"> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn Header="Projection" UniqueName="Name" DataMemberBinding="{Binding}" CellTemplate="{StaticResource CellTemplate.TaskName}" IsReadOnly="True"/> <telerik:GridViewDataColumn Header="Run Parameter Set" UniqueName="RunParametersLink" DataMemberBinding="{Binding}" CellTemplate="{StaticResource CellTemplate.RunParameterSetName}" IsReadOnly="True"/> </telerik:RadGridView.Columns> <telerik:RadGridView.ContextMenu> <ContextMenu> <MenuItem Header="Run Selected Item(s)" DataContext="{Binding Path=PlacementTarget.DataContext, RelativeSource={RelativeSource AncestorType=ContextMenu}}" Command="{Binding RunAllSelectedTasksCommand}" CommandParameter="{Binding Path=PlacementTarget.SelectedContexts, RelativeSource={RelativeSource AncestorType=ContextMenu}, Converter={StaticResource runControllerJobCmdConverter}}"> <MenuItem.Icon> <Image Source="Images/Run16.png" /> </MenuItem.Icon> </MenuItem> </ContextMenu> </telerik:RadGridView.ContextMenu> </telerik:RadGridView> </DataTemplate> </telerik:RadGridView.HierarchyChildTemplate> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn Header="Run Page Name" UniqueName="Name" CellTemplate="{StaticResource CellTemplate.RunPageName}" DataMemberBinding="{Binding}" IsReadOnly="True"/> <telerik:GridViewDataColumn Header="Target Model Object" UniqueName="AssociatedTargetModelObjectLink" DataMemberBinding="{Binding}" CellTemplate="{StaticResource CellTemplate.TargetModelObjectName}" IsReadOnly="True"/> <telerik:GridViewDataColumn Header="InputManager" UniqueName="AssociatedInputManagerLink" CellTemplate="{StaticResource CellTemplate.InputManagersList}" DataMemberBinding="{Binding}" IsReadOnly="True"/> </telerik:RadGridView.Columns> <telerik:RadGridView.ContextMenu> <ContextMenu> <MenuItem Header="Run Selected Item(s)" DataContext="{Binding Path=PlacementTarget.DataContext, RelativeSource={RelativeSource AncestorType=ContextMenu}}" Command="{Binding RunAllSelectedTasksCommand}" CommandParameter="{Binding Path=PlacementTarget.SelectedContexts, RelativeSource={RelativeSource AncestorType=ContextMenu}, Converter={StaticResource runControllerJobCmdConverter}}"> <MenuItem.Icon> <Image Source="Images/Run16.png" /> </MenuItem.Icon> </MenuItem> </ContextMenu> </telerik:RadGridView.ContextMenu> </telerik:RadGridView>The context menu in the parent grid is fine, but the one in the nested grid is not right.
Side question. Is there a better way to do the nested grid thing than the HierachyTemplate? I would like for this to be one grid that does nesting. I tried using ChildTableDefinitions, but I can't specify things like columns and what not.
Thanks,
Greg