Created
September 24, 2013 19:27
-
-
Save julesx/6689992 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Window x:Class="WpfApplication5.MainWindow" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
Title="MainWindow" Height="350" Width="525"> | |
<Window.Resources> | |
<Storyboard x:Key="animate"> | |
<ObjectAnimationUsingKeyFrames BeginTime="0:0:0" Storyboard.TargetProperty="Visibility"> | |
<DiscreteObjectKeyFrame KeyTime="0"> | |
<DiscreteObjectKeyFrame.Value> | |
<Visibility>Visible</Visibility> | |
</DiscreteObjectKeyFrame.Value> | |
</DiscreteObjectKeyFrame> | |
</ObjectAnimationUsingKeyFrames> | |
<DoubleAnimation BeginTime="0:0:0.0" Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:0.2"/> | |
<DoubleAnimation BeginTime="0:0:2.5" Storyboard.TargetProperty="Opacity" From="1" To="0" Duration="0:0:0.5"/> | |
<ObjectAnimationUsingKeyFrames BeginTime="0:0:5.5" Storyboard.TargetProperty="Visibility"> | |
<DiscreteObjectKeyFrame KeyTime="0"> | |
<DiscreteObjectKeyFrame.Value> | |
<Visibility>Hidden</Visibility> | |
</DiscreteObjectKeyFrame.Value> | |
</DiscreteObjectKeyFrame> | |
</ObjectAnimationUsingKeyFrames> | |
</Storyboard> | |
</Window.Resources> | |
<StackPanel Orientation="Vertical"> | |
<StackPanel.Resources> | |
<Style x:Key="HiddenTabItem" TargetType="{x:Type TabItem}"> | |
<Setter Property="Template"> | |
<Setter.Value> | |
<ControlTemplate TargetType="{x:Type TabItem}"> | |
<Border x:Name="TabHeader" BorderThickness="1,1,0,1" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" Padding="{TemplateBinding Padding}"> | |
<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" VerticalAlignment="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" ContentSource="Header" RecognizesAccessKey="True"/> | |
</Border> | |
<ControlTemplate.Triggers> | |
<EventTrigger RoutedEvent="Border.MouseEnter"> | |
<BeginStoryboard Name="animate_BeginStoryBoard" Storyboard="{StaticResource animate}" /> | |
</EventTrigger> | |
<EventTrigger RoutedEvent="MouseEnter" SourceName="TabHeader"> | |
<PauseStoryboard BeginStoryboardName="animate_BeginStoryBoard" /> | |
</EventTrigger> | |
<!--<EventTrigger RoutedEvent="MouseLeave" SourceName="TabHeader"> | |
<ResumeStoryboard BeginStoryboardName="animate_BeginStoryBoard" /> | |
</EventTrigger>--> | |
</ControlTemplate.Triggers> | |
</ControlTemplate> | |
</Setter.Value> | |
</Setter> | |
</Style> | |
</StackPanel.Resources> | |
<Border MouseEnter="UIElement_OnMouseEnter" Width="100" Height="100" BorderBrush="Black" BorderThickness="2"> | |
<TextBlock Text="Mouse Over to Show Tabs" TextWrapping="Wrap" HorizontalAlignment="Center" TextAlignment="Center" VerticalAlignment="Center" /> | |
</Border> | |
<TabControl> | |
<TabItem Name="Tab1" Style="{StaticResource HiddenTabItem}" Visibility="Hidden" Header="Tab 1"> | |
<Border Width="100" Height="100" BorderBrush="Red" BorderThickness="2"> | |
<TextBlock Text="Random content that should not affect tabs whatsoever" TextAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="Wrap" /> | |
</Border> | |
</TabItem> | |
<TabItem Name="Tab2" Style="{StaticResource HiddenTabItem}" Visibility="Hidden" Header="Tab 2"> | |
<Border Width="100" Height="100" BorderBrush="Violet" BorderThickness="2"> | |
<TextBlock Text="Random content that should not affect tabs whatsoever" TextAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="Wrap" /> | |
</Border> | |
</TabItem> | |
</TabControl> | |
</StackPanel> | |
</Window> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment