Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a TabControl that has a frame in each TabItem. I only listed one TabItem below for simplicity. Whenever I move my mouse over any control in the frame, the IsMouseOver style change occurs on the selected TabItem in the TabControl and changes to Gray. What am I doing wrong?

Update: I seperated the ControlTemplate from the style and set the template of the button to use the ControlTemplate and no styling. It seems to be a problem with the ControlTemplate, because it still happens.

XML
<TabControl Margin="10" BorderThickness="0" TabStripPlacement="Left" SnapsToDevicePixels="True" >
         <TabItem Header="General"  Style="{DynamicResource TopItem}"  Tag="Top" >

             <Frame NavigationUIVisibility="Hidden"   Source="Settings.xaml" />

         </TabItem>

     </TabControl>




XML
<Style TargetType="TabItem"  x:Key="TopItem">
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">

                <Setter Property="Foreground" Value="White" />
            </Trigger>
        </Style.Triggers>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="FontFamily" Value="Georgia"/>
        <Setter Property="FontSize" Value="14"/>

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Grid x:Name="Panel" >
                        <Border x:Name="ItemBorder" BorderThickness="1,0,1,0"     BorderBrush="Black"  Padding="10" Width="150">

                            <ContentPresenter x:Name="ContentSite"
        							VerticalAlignment="Center"
        							HorizontalAlignment="Center"
        							ContentSource="Header"
        							/>
                        </Border>

                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Tag" Value="Top">
                            <Setter TargetName="ItemBorder" Property="BorderThickness" Value="1,1,1,0" />
                            <!--<Setter TargetName="ItemBorder" Property="CornerRadius" Value="5,5,0,0" />-->

                        </Trigger>
                        <Trigger Property="Tag" Value="Bottom">
                            <Setter TargetName="ItemBorder" Property="BorderThickness" Value="1,0,1,1" />
                            <!--<Setter TargetName="ItemBorder" Property="CornerRadius" Value="0,0,5,5" />-->

                        </Trigger>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter TargetName="ItemBorder" Property="Background" Value="#FF124E8D" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="ItemBorder" Property="Background" Value="Gray" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
Posted
Updated 8-Apr-14 16:55pm
v3

1 solution

I had to add SourceName="ContentSite" for some reason.

XML
<trigger property="IsMouseOver" value="True" sourcename="ContentSite">
               <setter targetname="ItemBorder" property="Background" value="Gray" />
           </trigger>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900