0

嗨,我想在后面的代码中访问在 datagrid(下面的 xaml)中找到的扩展器,请告诉我解决方案,提前谢谢

我的 xml 代码如下:

<dg:DataGrid Margin="0,14,0,0"  Grid.Row="1" BorderThickness="0" PreviewMouseLeftButtonDown="mouse_Downs"   MouseDoubleClick="CustomDataGrid_MouseDoubleClick"  RowEditEnding="CustomDataGrid_RowEditEnding" Grid.RowSpan="6" AlternationCount="2"  SelectionMode="Single" SelectionUnit="FullRow" x:Name="CustomDataGrid" CanUserResizeColumns="False" AutoGenerateColumns="False" SelectionChanged="CustomDataGrid_SelectionChanged" ColumnHeaderStyle="{StaticResource columnHeaderStyle}" CanUserAddRows="False" CanUserDeleteRows="False" IsReadOnly="False" RowStyle="{StaticResource DataGridRowStyle}" GridLinesVisibility="None"  HeadersVisibility="Column"  CanUserSortColumns="False" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
    <dg:DataGrid.GroupStyle>
        <GroupStyle>
            <GroupStyle.HeaderTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Path=Name}" FontFamily="Calibri" Foreground="#FF055B72" FontWeight="Bold" FontSize="11"/>
                    </StackPanel>
                </DataTemplate>
            </GroupStyle.HeaderTemplate>
            <GroupStyle.ContainerStyle>
                <Style TargetType="{x:Type GroupItem}">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type GroupItem}">
                                <Expander Style="{StaticResource ExpanderStyle}"  x:Name="RowExpand" IsExpanded="True" Cursor="Hand" >
                                    <!--<Expander.Background>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#FFC7C7C7" Offset="1"/>
                                            <GradientStop Color="#FFEAE9E9"/>
                                            <GradientStop Color="#FFEBE8E8" Offset="0.37"/>
                                        </LinearGradientBrush>
                                    </Expander.Background>-->
                                    <Expander.Header>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock x:Name="txtGroupHeader" Text="{Binding Path=Name}" FontFamily="Calibri" Foreground="#FF47494F"  FontWeight="Bold" FontSize="14"/>
                                            <!--<Button Width="90" Height="25" Content="Sample"/>-->
                                        </StackPanel>
                                    </Expander.Header>
                                    <ItemsPresenter  Margin="7,5,7,9"/>
                                </Expander>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </GroupStyle.ContainerStyle>
        </GroupStyle>
    </dg:DataGrid.GroupStyle>
4

1 回答 1

0

您不能直接以样式访问它。您可以做的是获取样式(如在这篇文章中解释:我可以在代码隐藏中获取样式的键吗?(WPF)),然后通过您的样式访问扩展器对象。

于 2013-03-06T07:54:22.847 回答