J'ai créé un style pour Tab Control et TabItem dans un fichier xaml.Sur la sélection Tabitem, Style ne fonctionne pas
Lorsque TabControl est en cours de chargement première fois sur la fenêtre, son style d'application comme il le voulait. Mais lorsque je sélectionne un autre tabItem, son style de propriété IsSelection n'est pas exécuté.
Lors de la sélection : Trajectoire de tracé = "bleu" et arrière-plan de Bd = "jaune".
S'il vous plaît, aidez-moi à trier ce numéro.
Merci à l'avance.
<Style x:Key="SimpleTabItemStyle" TargetType="{x:Type TabControl}">
<Setter Property="Padding" Value="4,4,4,0"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="{DynamicResource WhiteColorBrush}"/>
<Setter Property="Background" Value="{DynamicResource NormalBrush}"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabControl}">
<Grid ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="ColumnDefinition0" Width="480"/>
<ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition x:Name="RowDefinition0" Height="30"/>
<RowDefinition x:Name="RowDefinition1" Height="*"/>
</Grid.RowDefinitions>
<TabPanel x:Name="HeaderPanel" IsItemsHost="true" Margin="2,2,2,0" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1"/>
<Border x:Name="ContentPanel"
CornerRadius="0,5,5,5"
BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{DynamicResource NormalBrush}" KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="1" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource WhiteColorBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="MediumTabItemStyle" TargetType="{x:Type TabItem}">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="Padding" Value="3,1"/>
<Setter Property="Focusable" Value="True"/>
<Setter Property="Width" Value="105px"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}" >
<Grid SnapsToDevicePixels="true" Height="32" Focusable="False">
<Path x:Name="Bd" Fill="{DynamicResource NormalBrush}" StrokeThickness="2" Stroke="Blue" Data="M32.112576,21.370581 C32.11147,19.654586 32.018481,10.83178 32.130291,
2.8647957 32.168301,0.15634975 32.890504,-0.063229885 33.673263,-0.10401306 33.673263,-0.10401306 46.603605,-0.10439528 46.603605,-0.10439528 48.464699,-0.081679943 48.572192,13.549447 50.678186,21.503142" Stretch="Fill" Width="105px" Cursor="Hand" />
<TextBlock x:Name="Content" Padding="1" TextWrapping="WrapWithOverflow" Width="95" Foreground="{DynamicResource BlackColorBrush}" HorizontalAlignment="Left" TextBlock.TextAlignment="Center" VerticalAlignment="center"
Text="{Binding Header, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabItem}}}" ToolTip="{Binding Header, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabItem}}}" TextTrimming="CharacterEllipsis"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="False">
<Setter Property="ToolTip" TargetName="Content" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem},Mode=FindAncestor},Path=Header}"/>
<Setter Property="Fill" TargetName="Bd" Value="{DynamicResource UnSelectedBrush}"/>
<!--<Setter Property="TextTrimming" TargetName="Content" Value="CharacterEllipsis"/>-->
<Setter Property="Panel.ZIndex" Value="0"/>
<Setter Property="Stroke" TargetName="Bd" Value="{DynamicResource WhiteColorBrush}"/>
<Setter Property="Margin" Value="0,0,0,-1" TargetName="Bd"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="Opacity" Value="0.6"/>
<Setter Property="Cursor" TargetName="Bd" Value="Hand" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Margin" Value="0,0,0,-3" TargetName="Bd"/>
<Setter Property="Fill" TargetName="Bd" Value="{DynamicResource NormalBrush}"/>
<Setter Property="Stroke" TargetName="Bd" Value="Yellow"/>
<Setter Property="StrokeThickness" TargetName="Bd" Value="2"/>
<!--<Setter Property="TextBlock.FontWeight" TargetName="Content" Value="DemiBold"/>-->
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="false"/>
<Condition Property="IsMouseOver" Value="true"/>
</MultiTrigger.Conditions>
<Setter Property="Margin" Value="-1" TargetName="Bd"/>
<Setter Property="Fill" TargetName="Bd" Value="{DynamicResource UnSelectedItemBrush}"/>
<Setter Property="Cursor" TargetName="Bd" Value="Hand"/>
<!--<Setter Property="TextBlock.FontWeight" TargetName="Content" Value="DemiBold"/>-->
</MultiTrigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Fill" TargetName="Bd" Value="{DynamicResource DisabledBackgroundBrush}"/>
<Setter Property="Foreground" TargetName="Content" Value="{DynamicResource WhiteColorBrush}"/>
<Setter Property="Cursor" TargetName="Bd" Value="Hand"/>
<Setter Property="Margin" Value="0,0,0,-3" TargetName="Bd"/>
<Setter Property="Fill" TargetName="Bd" Value="{DynamicResource NormalBrush}"/>
<Setter Property="Stroke" TargetName="Bd" Value="Yellow"/>
<Setter Property="StrokeThickness" TargetName="Bd" Value="2"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
, vous voulez atteindre: quand l'élément est sélectionné, le trait d'être « bleu » et l'arrière-plan pour être « jaune »? – Iron
Oui, En sélection Le déclencheur ne fonctionne pas @Iron –
Comment est votre 'NormalBrush'? – Iron