TargetType =“{x:Type GroupItem}”wpf中的箭头样式

时间:2010-09-08 07:04:01

标签: wpf styles expander

如何更改<wpftoolkit:DataGrid.GroupStyle>

的箭头样式

1 个答案:

答案 0 :(得分:0)

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

        <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>

感谢所有