TargetType="{x:Type GroupItem}" WPF中的箭头样式

发布于 2024-09-18 08:35:51 字数 96 浏览 4 评论 0 原文

如何更改 的箭头样式

How to change arrow style for <wpftoolkit:DataGrid.GroupStyle>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

热鲨 2024-09-25 08:35:51

请找到上述问题的解决方案

        <ControlTemplate x:Key="newToggleButtonControlTemplate" TargetType="{x:Type ToggleButton}">
            <Grid>
                <Ellipse Fill="{DynamicResource ExpanderArrowFill}" 
                         Stroke="DarkGray" 
                         HorizontalAlignment="Center" 
                         x:Name="circle"                       
                         VerticalAlignment="Center" 
                         Width="20" Height="20"/>
                <Path 
                x:Name="Up_Arrow" 
                HorizontalAlignment="Center" 
                VerticalAlignment="Center" 
                Fill="White" 
                Data="M 0 0 L 5 5 L 10 0 Z" />

                <Path 
                x:Name="Down_Arrow" 
                Visibility="Collapsed" 
                HorizontalAlignment="Center" 
                VerticalAlignment="Center" 
                Fill="White"                     
                Data="M 0 5 L 5 0 L 10 5 Z" />
            </Grid>
            <ControlTemplate.Triggers>
                <Trigger Property="IsMouseOver" Value="true">
                    <Setter Property="Fill" Value="{DynamicResource MouseOverBrush}" TargetName="circle"/>
                </Trigger>
                <Trigger Property="IsPressed" Value="true">
                    <Setter Property="Fill" Value="{DynamicResource PressedBrush}" TargetName="circle"/>
                </Trigger>
                <Trigger Property="IsChecked" Value="true">
                    <Setter Property="Visibility" Value="Visible" TargetName="Down_Arrow"/>
                    <Setter Property="Visibility" Value="Collapsed" TargetName="Up_Arrow"/>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
        <Style x:Key="newExpanderStyle" TargetType="{x:Type Expander}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Expander}">
                        <Grid Background="#720151">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*" x:Name="ContentRow"/>
                            </Grid.RowDefinitions>
                            <Border 
                            x:Name="Border" 
                            Grid.Row="0" 
                            BorderThickness="{TemplateBinding BorderThickness}" 
                            CornerRadius="2,2,0,0" >
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="20"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>

                                    <ToggleButton                                              
                                    Template="{DynamicResource newToggleButtonControlTemplate}"                                                                                    
                                    IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"  OverridesDefaultStyle="True" />
                                    <ContentPresenter Grid.Column="1" Margin="4" RecognizesAccessKey="True" ContentSource="Header"  />
                                </Grid>
                            </Border>
                            <Border 
                            x:Name="ExpandSite" 
                            Grid.Row="1" 
                            Visibility="Collapsed" 
                            BorderThickness="1,0,1,1" 
                            CornerRadius="0,0,2,2" >
                                <ContentPresenter 
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"                                         
                                Focusable="false"/>
                            </Border>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsExpanded" Value="True">
                                <Setter Property="Visibility" Value="Visible" TargetName="ExpandSite"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

感谢大家

Please find the solution for the above question

        <ControlTemplate x:Key="newToggleButtonControlTemplate" TargetType="{x:Type ToggleButton}">
            <Grid>
                <Ellipse Fill="{DynamicResource ExpanderArrowFill}" 
                         Stroke="DarkGray" 
                         HorizontalAlignment="Center" 
                         x:Name="circle"                       
                         VerticalAlignment="Center" 
                         Width="20" Height="20"/>
                <Path 
                x:Name="Up_Arrow" 
                HorizontalAlignment="Center" 
                VerticalAlignment="Center" 
                Fill="White" 
                Data="M 0 0 L 5 5 L 10 0 Z" />

                <Path 
                x:Name="Down_Arrow" 
                Visibility="Collapsed" 
                HorizontalAlignment="Center" 
                VerticalAlignment="Center" 
                Fill="White"                     
                Data="M 0 5 L 5 0 L 10 5 Z" />
            </Grid>
            <ControlTemplate.Triggers>
                <Trigger Property="IsMouseOver" Value="true">
                    <Setter Property="Fill" Value="{DynamicResource MouseOverBrush}" TargetName="circle"/>
                </Trigger>
                <Trigger Property="IsPressed" Value="true">
                    <Setter Property="Fill" Value="{DynamicResource PressedBrush}" TargetName="circle"/>
                </Trigger>
                <Trigger Property="IsChecked" Value="true">
                    <Setter Property="Visibility" Value="Visible" TargetName="Down_Arrow"/>
                    <Setter Property="Visibility" Value="Collapsed" TargetName="Up_Arrow"/>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
        <Style x:Key="newExpanderStyle" TargetType="{x:Type Expander}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Expander}">
                        <Grid Background="#720151">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*" x:Name="ContentRow"/>
                            </Grid.RowDefinitions>
                            <Border 
                            x:Name="Border" 
                            Grid.Row="0" 
                            BorderThickness="{TemplateBinding BorderThickness}" 
                            CornerRadius="2,2,0,0" >
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="20"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>

                                    <ToggleButton                                              
                                    Template="{DynamicResource newToggleButtonControlTemplate}"                                                                                    
                                    IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"  OverridesDefaultStyle="True" />
                                    <ContentPresenter Grid.Column="1" Margin="4" RecognizesAccessKey="True" ContentSource="Header"  />
                                </Grid>
                            </Border>
                            <Border 
                            x:Name="ExpandSite" 
                            Grid.Row="1" 
                            Visibility="Collapsed" 
                            BorderThickness="1,0,1,1" 
                            CornerRadius="0,0,2,2" >
                                <ContentPresenter 
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"                                         
                                Focusable="false"/>
                            </Border>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsExpanded" Value="True">
                                <Setter Property="Visibility" Value="Visible" TargetName="ExpandSite"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

Thanks to all

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文