I have a muliple hierarchy Gridview with a context menu and I would like to pass the current row from the grid when clicking a particular item from grid, however when I do check check for the method handler in the VM, the parameter is always null.
What I would like to do is get access to the Row datacontext in the grid when a user clicks on the menu.
XAML code:
<telerik:RadGridView RowIndicatorVisibility="Hidden" SelectionMode="Single" SelectionUnit="FullRow" SelectedCellsChanged="RadGridView_OnSelectedCellsChanged" x:Name="radGridView" Margin="10" ItemsSource="{Binding Enquiries}" ShowGroupPanel="False" AutoGenerateColumns="False" Height="380" IsFilteringAllowed="False" DataLoaded="RadGridView1_OnDataLoaded">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Sorting">
<cmd:EventToCommand Command="{Binding SortingCommand}" PassEventArgsToCommand="True"></cmd:EventToCommand>
</i:EventTrigger>
</i:Interaction.Triggers>
<telerik:RadContextMenu.ContextMenu>
<telerik:RadContextMenu>
<i:Interaction.Triggers>
<i:EventTrigger EventName="ItemClick">
<cmd:EventToCommand Command="{Binding GetEnquiryCommand}" CommandParameter="{Binding ElementName=radGridView, Path=SelectedRow}"></cmd:EventToCommand>
</i:EventTrigger>
</i:Interaction.Triggers> <telerik:RadMenuGroupItem Background="LightSkyBlue">
<telerik:RadMenuItem Header="Mark as Complete"></telerik:RadMenuItem>
<telerik:RadMenuItem Header="Link to UW Reference"></telerik:RadMenuItem>
</telerik:RadMenuGroupItem>
<telerik:RadMenuGroupItem Background="LightSkyBlue">
<telerik:RadMenuItem Header="Edit Enquiry">
</telerik:RadMenuItem>
<telerik:RadMenuItem Header="View Enquiry">
</telerik:RadMenuItem>
</telerik:RadMenuGroupItem>
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
<telerik:RadGridView.ChildTableDefinitions>
<telerik:GridViewTableDefinition/>
</telerik:RadGridView.ChildTableDefinitions>
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding EnquiryId}" Header="ID" IsCustomSortingEnabled="True" HeaderCellStyle="{StaticResource HeaderCellStyle}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding AssuredName}" Header="Assured" IsCustomSortingEnabled="True" HeaderCellStyle="{StaticResource HeaderCellStyle}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding RaterModelVersion.RaterModel.RaterModelName}" Header="Product" IsCustomSortingEnabled="True" HeaderCellStyle="{StaticResource HeaderCellStyle}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding BrokerName}" Header="Broker Name" IsCustomSortingEnabled="True" HeaderCellStyle="{StaticResource HeaderCellStyle}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding EnquiryStatus}" Header="Status" IsSortable="False" HeaderCellStyle="{StaticResource HeaderCellStyle}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Underwriter}" Header="UW" IsSortable="False" HeaderCellStyle="{StaticResource HeaderCellStyle}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding ChangedDate}" Header="Modified Date" IsCustomSortingEnabled="True" HeaderCellStyle="{StaticResource HeaderCellStyle}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding ChangedBy}" Header="Modified By" IsSortable="False" HeaderCellStyle="{StaticResource HeaderCellStyle}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Comments}" Header="UW Comments" IsSortable="False" HeaderCellStyle="{StaticResource HeaderCellStyle}" Width="*"/>
</telerik:RadGridView.Columns>
<telerik:RadGridView.SortDescriptors>
<telerik:ColumnSortDescriptor Column="{Binding Columns[\AssuredName\], ElementName=radGridView}"
SortDirection="Ascending" />
</telerik:RadGridView.SortDescriptors>
<telerik:RadGridView.HierarchyChildTemplate>
<DataTemplate>
<telerik:RadGridView RowIndicatorVisibility="Hidden" ItemsSource="{Binding SectionLayers}" AutoGenerateColumns="False" ShowGroupPanel="False" CanUserSortColumns="False" IsFilteringAllowed="False" DataLoaded="RadGridView1_OnDataLoaded" Width="Auto">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding PolicyReference}" Header="UW Reference" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding SegmentSectionLayer}" Header="Identifiers"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding LimitAt100Percent}" Header="Limits"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding ExcessAt100Percent}" Header="Excess"/>
</telerik:RadGridView.Columns>
<telerik:RadGridView.ChildTableDefinitions>
<telerik:GridViewTableDefinition/>
</telerik:RadGridView.ChildTableDefinitions>
<telerik:RadGridView.HierarchyChildTemplate>
<DataTemplate>
<telerik:RadGridView RowIndicatorVisibility="Hidden" ItemsSource="{Binding PremiumCurrencySplits}" AutoGenerateColumns="False" CanUserSortColumns="False" ShowGroupPanel="False" IsFilteringAllowed="False">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding PremiumCurrency}" Header="Premium Currency"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding ModelPrice}" Header="Model Price"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding TechnicalPrice}" Header="Tech Price"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding GrossGrossWrittenPremiumAt100Percentage}" Header="100% WRT Premium"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding ProjectedNetLossRatio}" Header="PLR"/>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</DataTemplate>
</telerik:RadGridView.HierarchyChildTemplate>
</telerik:RadGridView>
</DataTemplate>
</telerik:RadGridView.HierarchyChildTemplate>
</telerik:RadGridView>
Any ideas ? Here's my VM code:
private async void GetEnquiry(object enquiry) { }
What I would like to do is get access to the Row datacontext in the grid when a user clicks on the menu.
XAML code:
<telerik:RadGridView RowIndicatorVisibility="Hidden" SelectionMode="Single" SelectionUnit="FullRow" SelectedCellsChanged="RadGridView_OnSelectedCellsChanged" x:Name="radGridView" Margin="10" ItemsSource="{Binding Enquiries}" ShowGroupPanel="False" AutoGenerateColumns="False" Height="380" IsFilteringAllowed="False" DataLoaded="RadGridView1_OnDataLoaded">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Sorting">
<cmd:EventToCommand Command="{Binding SortingCommand}" PassEventArgsToCommand="True"></cmd:EventToCommand>
</i:EventTrigger>
</i:Interaction.Triggers>
<telerik:RadContextMenu.ContextMenu>
<telerik:RadContextMenu>
<i:Interaction.Triggers>
<i:EventTrigger EventName="ItemClick">
<cmd:EventToCommand Command="{Binding GetEnquiryCommand}" CommandParameter="{Binding ElementName=radGridView, Path=SelectedRow}"></cmd:EventToCommand>
</i:EventTrigger>
</i:Interaction.Triggers> <telerik:RadMenuGroupItem Background="LightSkyBlue">
<telerik:RadMenuItem Header="Mark as Complete"></telerik:RadMenuItem>
<telerik:RadMenuItem Header="Link to UW Reference"></telerik:RadMenuItem>
</telerik:RadMenuGroupItem>
<telerik:RadMenuGroupItem Background="LightSkyBlue">
<telerik:RadMenuItem Header="Edit Enquiry">
</telerik:RadMenuItem>
<telerik:RadMenuItem Header="View Enquiry">
</telerik:RadMenuItem>
</telerik:RadMenuGroupItem>
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
<telerik:RadGridView.ChildTableDefinitions>
<telerik:GridViewTableDefinition/>
</telerik:RadGridView.ChildTableDefinitions>
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding EnquiryId}" Header="ID" IsCustomSortingEnabled="True" HeaderCellStyle="{StaticResource HeaderCellStyle}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding AssuredName}" Header="Assured" IsCustomSortingEnabled="True" HeaderCellStyle="{StaticResource HeaderCellStyle}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding RaterModelVersion.RaterModel.RaterModelName}" Header="Product" IsCustomSortingEnabled="True" HeaderCellStyle="{StaticResource HeaderCellStyle}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding BrokerName}" Header="Broker Name" IsCustomSortingEnabled="True" HeaderCellStyle="{StaticResource HeaderCellStyle}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding EnquiryStatus}" Header="Status" IsSortable="False" HeaderCellStyle="{StaticResource HeaderCellStyle}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Underwriter}" Header="UW" IsSortable="False" HeaderCellStyle="{StaticResource HeaderCellStyle}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding ChangedDate}" Header="Modified Date" IsCustomSortingEnabled="True" HeaderCellStyle="{StaticResource HeaderCellStyle}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding ChangedBy}" Header="Modified By" IsSortable="False" HeaderCellStyle="{StaticResource HeaderCellStyle}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Comments}" Header="UW Comments" IsSortable="False" HeaderCellStyle="{StaticResource HeaderCellStyle}" Width="*"/>
</telerik:RadGridView.Columns>
<telerik:RadGridView.SortDescriptors>
<telerik:ColumnSortDescriptor Column="{Binding Columns[\AssuredName\], ElementName=radGridView}"
SortDirection="Ascending" />
</telerik:RadGridView.SortDescriptors>
<telerik:RadGridView.HierarchyChildTemplate>
<DataTemplate>
<telerik:RadGridView RowIndicatorVisibility="Hidden" ItemsSource="{Binding SectionLayers}" AutoGenerateColumns="False" ShowGroupPanel="False" CanUserSortColumns="False" IsFilteringAllowed="False" DataLoaded="RadGridView1_OnDataLoaded" Width="Auto">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding PolicyReference}" Header="UW Reference" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding SegmentSectionLayer}" Header="Identifiers"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding LimitAt100Percent}" Header="Limits"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding ExcessAt100Percent}" Header="Excess"/>
</telerik:RadGridView.Columns>
<telerik:RadGridView.ChildTableDefinitions>
<telerik:GridViewTableDefinition/>
</telerik:RadGridView.ChildTableDefinitions>
<telerik:RadGridView.HierarchyChildTemplate>
<DataTemplate>
<telerik:RadGridView RowIndicatorVisibility="Hidden" ItemsSource="{Binding PremiumCurrencySplits}" AutoGenerateColumns="False" CanUserSortColumns="False" ShowGroupPanel="False" IsFilteringAllowed="False">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding PremiumCurrency}" Header="Premium Currency"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding ModelPrice}" Header="Model Price"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding TechnicalPrice}" Header="Tech Price"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding GrossGrossWrittenPremiumAt100Percentage}" Header="100% WRT Premium"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding ProjectedNetLossRatio}" Header="PLR"/>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</DataTemplate>
</telerik:RadGridView.HierarchyChildTemplate>
</telerik:RadGridView>
</DataTemplate>
</telerik:RadGridView.HierarchyChildTemplate>
</telerik:RadGridView>
Any ideas ? Here's my VM code:
private async void GetEnquiry(object enquiry) { }