Note that there are some explanatory texts on larger screens.

plurals
  1. POTrigger for IsMouseOver on TabItem ContenTemplate
    primarykey
    data
    text
    <p>I have a problem with a TabItem Style and maybe someone of you can help me.</p> <p>Following the Style at issue:</p> <pre><code>&lt;Style x:Key="ChildrenTabItemStyle" TargetType="TabItem"&gt; &lt;Style.Resources&gt; &lt;SolidColorBrush x:Key="ButtonNormalBackground" Color="#FFEAE8E8"/&gt; &lt;LinearGradientBrush x:Key="ButtonOverBackground" EndPoint="0,1" StartPoint="0,0"&gt; &lt;GradientStop Color="#FFFAFAFA" Offset="0"/&gt; &lt;GradientStop Color="#FFE0E0E3" Offset="1"/&gt; &lt;/LinearGradientBrush&gt; &lt;LinearGradientBrush x:Key="ButtonPressedBackground" EndPoint="0,1" StartPoint="0,0"&gt; &lt;GradientStop Color="#FFE0E0E2" Offset="0"/&gt; &lt;GradientStop Color="#FFF8F8F8" Offset="1"/&gt; &lt;/LinearGradientBrush&gt; &lt;SolidColorBrush x:Key="ButtonNormalBorder" Color="#FF969696"/&gt; &lt;Style x:Key="CloseableTabItemButtonStyle" TargetType="{x:Type Button}"&gt; &lt;Setter Property="FocusVisualStyle" Value="{x:Null}"/&gt; &lt;Setter Property="Background" Value="{DynamicResource ButtonNormalBackground}"/&gt; &lt;Setter Property="BorderBrush" Value="Transparent"/&gt; &lt;Setter Property="BorderThickness" Value="2,2,2,0"/&gt; &lt;Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/&gt; &lt;Setter Property="HorizontalContentAlignment" Value="Center"/&gt; &lt;Setter Property="VerticalContentAlignment" Value="Center"/&gt; &lt;Setter Property="Padding" Value="4"/&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type Button}"&gt; &lt;Grid&gt; &lt;Border SnapsToDevicePixels="true" x:Name="Chrome" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2" Opacity="0" /&gt; &lt;ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/&gt; &lt;/Grid&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="IsMouseOver" Value="True"&gt; &lt;Setter Property="Opacity" TargetName="Chrome" Value="1"/&gt; &lt;Setter Property="Background" TargetName="Chrome" Value="{DynamicResource ButtonOverBackground}" /&gt; &lt;/Trigger&gt; &lt;Trigger Property="IsPressed" Value="True"&gt; &lt;Setter Property="Opacity" TargetName="Chrome" Value="1"/&gt; &lt;Setter Property="Background" TargetName="Chrome" Value="{DynamicResource ButtonPressedBackground}" /&gt; &lt;/Trigger&gt; &lt;Trigger Property="IsEnabled" Value="false"&gt; &lt;Setter Property="Foreground" Value="#ADADAD"/&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/Style.Resources&gt; &lt;Setter Property="Height" Value="40"/&gt; &lt;Setter Property="MinWidth" Value="90"/&gt; &lt;Setter Property="FontWeight" Value="Bold"/&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type TabItem}"&gt; &lt;Border Name="Border" Margin="1,-1,-1,-1"&gt; &lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="*"/&gt; &lt;ColumnDefinition Width="Auto"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;ContentPresenter Name="BorderContent" Content="{Binding Path=Header}" VerticalAlignment="Center" HorizontalAlignment="Center"/&gt; &lt;Button x:Name="PART_Close" HorizontalAlignment="Right" Margin="3,0,3,0" VerticalAlignment="Top" Width="16" Height="16" DockPanel.Dock="Right" Style="{DynamicResource CloseableTabItemButtonStyle}" ToolTip="Close Tab" Cursor="Hand" Command="{Binding Path=CloseCommand}" Visibility="Hidden"&gt; &lt;Path x:Name="Path" Stretch="Fill" StrokeThickness="0.5" Stroke="#FF333333" Fill="#FF969696" Data="F1 M 2.28484e-007,1.33331L 1.33333,0L 4.00001,2.66669L 6.66667,6.10352e-005L 8,1.33331L 5.33334,4L 8,6.66669L 6.66667,8L 4,5.33331L 1.33333,8L 1.086e-007,6.66669L 2.66667,4L 2.28484e-007,1.33331 Z " HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/&gt; &lt;/Button&gt; &lt;/Grid&gt; &lt;/Border&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="IsMouseOver" Value="True"&gt; &lt;Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource ButtonBorderBrush}"/&gt; &lt;Setter TargetName="Border" Property="BorderThickness" Value="2,2,2,0"/&gt; &lt;Setter TargetName="PART_Close" Property="Visibility" Value="Visible"/&gt; &lt;/Trigger&gt; &lt;Trigger Property="IsSelected" Value="True"&gt; &lt;Setter TargetName="Border" Property="Background" Value="{StaticResource EnvLayout}"/&gt; &lt;Setter Property="Foreground" Value="#FFFFFF"/&gt; &lt;Setter TargetName="PART_Close" Property="Visibility" Value="Visible"/&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>My problem is focused on IsMouseOver trigger; when a tab is not selected, in fact, this event is fired only when the cursor is over the Header of the TabItem ( defined within the ContentTemplate) and not at any point of the Border.</p> <p>In order to better explain my problem, following some screenshots:</p> <p>When IsMouseOver = true my TabItem must have a gray border and the close button has to appear; as you can see in the following images, this behaviour appens only when my cursor is exactly over the Header:</p> <p><img src="https://i.stack.imgur.com/5EkQJ.jpg" alt="Cursor over the Header"></p> <p><img src="https://i.stack.imgur.com/RH88c.jpg" alt="Curson near the edge of the border"></p> <p>Obviously, when the cursor isn't over the Header,you cannot even select the Tab.</p> <p>How can I solve this problem??</p> <p>Thanks in advance for your help,</p> <p>Deborah</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload