0

我有一个 RadGridView,它对它的内容进行分组。我在组标题上有一个按钮 当我单击按钮 (btnSave) 时,我想访问组以读取组密钥。

我可以在 btnSave 的 Click 中添加什么来完成此操作?

<telerik:RadGridView x:Name="grdNotams" Grid.Row="1" AutoGenerateColumns="False" RowIndicatorVisibility="Collapsed" ShowGroupPanel="False">
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn  UniqueName="colNewStatus" DataMemberBinding="{Binding NewStatus}" Header="New Status" IsFilterable="False" IsSortable="False">
            <telerik:GridViewDataColumn.CellTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <telerik:RadRadioButton Content="C" Width="30" IsChecked="{Binding NewStatus, Mode=TwoWay, Converter={StaticResource StringToBooleanConverter},ConverterParameter=C}" GroupName="{Binding RadioButtonName}"/>
                        <telerik:RadRadioButton Content="M" Width="30" Margin="5,0,0,0"  IsChecked="{Binding NewStatus, Mode=TwoWay, Converter={StaticResource StringToBooleanConverter},ConverterParameter=M}" GroupName="{Binding RadioButtonName}"/>
                        <telerik:RadRadioButton Content="I" Width="30" Margin="5,0,0,0"  IsChecked="{Binding NewStatus, Mode=TwoWay, Converter={StaticResource StringToBooleanConverter},ConverterParameter=I}" GroupName="{Binding RadioButtonName}"/>                                    
                    </StackPanel>
                </DataTemplate>
            </telerik:GridViewDataColumn.CellTemplate>
        </telerik:GridViewDataColumn>
        <telerik:GridViewDataColumn Header="Status" UniqueName="colStatus" DataMemberBinding="{Binding Model.Status, Converter={StaticResource StatusConverter}}" HeaderTextAlignment="Center" TextAlignment="Center" IsFilterable="False" IsSortable="False"/>
        <telerik:GridViewDataColumn Header="Trip #" UniqueName="colTripNumber" DataMemberBinding="{Binding Model.TripNumber}" HeaderTextAlignment="Center" TextAlignment="Center" IsFilterable="False" IsSortable="False"/>
        <telerik:GridViewDataColumn Header="Date" UniqueName="colDate" DataMemberBinding="{Binding Model.DepartureTime}" DataFormatString="d"  HeaderTextAlignment="Center" TextAlignment="Center" IsFilterable="False" IsSortable="False"/>
    </telerik:RadGridView.Columns>
    <telerik:RadGridView.GroupHeaderTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <telerik:RadButton x:Name="btnSave" Click="btnSave_Click">
                    <StackPanel Orientation="Vertical">
                        <Image Source="../images/save.jpg" Height="30" Width="30" HorizontalAlignment="Center"/>
                        <TextBlock TextAlignment="Center" TextWrapping="Wrap">Update</TextBlock>
                    </StackPanel>
                </telerik:RadButton>
                <TextBlock Text="{Binding Group.Key}" FontSize="14" FontWeight="Bold" FontStyle="{Binding EarliestNotamDepartureTime, Converter={StaticResource DateTimeToItalicsConverter}}" TextWrapping="Wrap" VerticalAlignment="Center" Padding="5"/>
            </StackPanel>
        </DataTemplate>
    </telerik:RadGridView.GroupHeaderTemplate>
    <telerik:RadGridView.GroupDescriptors>
        <telerik:GroupDescriptor Member="NotamGroup"  >
        </telerik:GroupDescriptor>
        <telerik:GroupDescriptor Member="Model.NotamText">
        </telerik:GroupDescriptor>
    </telerik:RadGridView.GroupDescriptors>
</telerik:RadGridView>
4

1 回答 1

0

弄清楚了。

DataContext 以 GroupViewModel 类的形式包含我需要的信息。

代码

private void btnSave_Click(object sender, RoutedEventArgs e)
{
    GroupViewModel vm = ((RadButton)sender).DataContext as GroupViewModel;
}
于 2013-02-02T19:11:15.143 回答