I'm looking for some way to combine storyboards into other storyboards in XAML.
In the following example, Thing1 and Thing2 are two TextBlocks that slide onto a Canvas from the top and bottom, respectively. I intend that only one, the other, or neither is visible at any time, so I set up three states in the VisualStateManager, inside a single VisualStateGroup, with Transitions among the various states.
I'd like to be able to write the Storyboards for Thing1ToThing2 and Thing2ToThing1 in the context of the other, simpler Storyboards. For instance, is there any way to have the storyboard Thing1ToThing2 call/invoke/reference/be composed of Thing1Out and Thing2In? The code can be duplicated, of course, but can we do any better than that? Or, is there a way to have the VisualTransitions do more?
I'd prefer to keep this in XAML, if possible, and in a way that scales for larger numbers of things.
Thanks!
-David
<UserControl x:Class="WpfApplication1.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="500" Height="500" Background="PaleTurquoise" >
<UserControl.Resources>
<Storyboard x:Key="Thing1In">
<DoubleAnimation Storyboard.TargetName="Thing1" Storyboard.TargetProperty="(Canvas.Top)" Duration="0:0:2" To="100" />
</Storyboard>
<Storyboard x:Key="Thing1Out">
<DoubleAnimation Storyboard.TargetName="Thing1" Storyboard.TargetProperty="(Canvas.Top)" Duration="0:0:2" To="-100" />
</Storyboard>
<Storyboard x:Key="Thing2In">
<DoubleAnimation Storyboard.TargetName="Thing2" Storyboard.TargetProperty="(Canvas.Bottom)" Duration="0:0:2" To="100" />
</Storyboard>
<Storyboard x:Key="Thing2Out">
<DoubleAnimation Storyboard.TargetName="Thing2" Storyboard.TargetProperty="(Canvas.Bottom)" Duration="0:0:2" To="-100" />
</Storyboard>
<Storyboard x:Key="Thing1ToThing2">
<!--do Thing1Out then (or at the same time as) Thing2In-->
</Storyboard>
<Storyboard x:Key="Thing2ToThing1">
<!--do Thing2Out then (or at the same time as) Thing1In-->
</Storyboard>
</UserControl.Resources>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ThingStates">
<VisualState x:Name="NothingInState" />
<VisualState x:Name="Thing1InState" Storyboard="{StaticResource Thing1In}" />
<VisualState x:Name="Thing2InState" Storyboard="{StaticResource Thing2In}" />
<VisualStateGroup.Transitions>
<VisualTransition From="Thing1InState" To="Thing2InState" Storyboard="{StaticResource Thing1ToThing2}" />
<VisualTransition From="Thing2InState" To="Thing1InState" Storyboard="{StaticResource Thing2ToThing1}" />
<VisualTransition From="Thing1InState" To="NothingInState" Storyboard="{StaticResource Thing1Out}" />
<VisualTransition From="Thing2InState" To="NothingInState" Storyboard="{StaticResource Thing2Out}" />
</VisualStateGroup.Transitions>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Canvas ClipToBounds="True">
<TextBlock x:Name="Thing1" Text="Thing1" FontSize="60" Canvas.Top="-100" Canvas.Left="100" />
<TextBlock x:Name="Thing2" Text="Thing2" FontSize="60" Canvas.Bottom="-100" Canvas.Left="100" />
</Canvas>
</UserControl>
Related
I am having a hard time understanding how to use the UWP VisualStateManager correctly. I have defined a UserControl containing some simple Visual States, Here is the XAML:
<UserControl
x:Class="BingSearch.Views.UserControls.VerticalsTabHeader"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Margin="8 0 8 0"
mc:Ignorable="d" IsTabStop="False">
<UserControl.Resources>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<VisualTransition From="Normal" To="Minimal"
GeneratedDuration="0:0:0.2">
</VisualTransition>
</VisualStateGroup.Transitions>
<VisualState x:Name="Normal">
</VisualState>
<VisualState x:Name="Minimal">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="BubbleGrid"
Storyboard.TargetProperty="Opacity" From="1" To="0" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</UserControl.Resources>
<StackPanel>
<Grid x:Name="BubbleGrid">
<Ellipse Width="60" Height="60" Fill="Black" Stroke="White" StrokeThickness="1" />
<FontIcon
HorizontalAlignment="Center"
VerticalAlignment="Center"
Glyph="{Binding Glyph}"
Foreground="White"
FontSize="26" />
</Grid>
</StackPanel>
</UserControl>
In my code behind, when I call VisualStateManager.GoToState(this, "Minimal", true);or VisualStateManager.GoToState(this, "Normal", true);, nothing happens. The return value of the calls are always false, and CommonStates.CurrentState is always null. It seems like my Visual States never got "hooked up" to the UserControl. Is this not the correct way to define Visual States for UserControls?
If you want to use the VisualStateManager correctly in the UserControl, you need to do the following two things:
First you need to wrap your VisualStateGroup inside the
<VisualStateManager.VisualStateGroups>
...
</VisualStateManager.VisualStateGroups>
After that you need to put the VisualStateManager to be the direct child of the Root control in the UserControl as following:
<StackPanel>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<VisualTransition From="Normal" To="Minimal"
GeneratedDuration="0:0:0.2">
</VisualTransition>
</VisualStateGroup.Transitions>
<VisualState x:Name="Normal">
</VisualState>
<VisualState x:Name="Minimal">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="BubbleGrid"
Storyboard.TargetProperty="Opacity" From="1" To="0" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid x:Name="BubbleGrid">
<Ellipse Width="60" Height="60" Fill="Black" Stroke="White" StrokeThickness="1" />
<FontIcon
HorizontalAlignment="Center"
VerticalAlignment="Center"
Glyph="{Binding Glyph}"
Foreground="White"
FontSize="26" />
</Grid>
</StackPanel>
The result:
I wanna change the border color of LoopingSelector so I copy the style definition of LoopingSelectorItem (as listed bleow) from Generic.xaml to my PhoneApplicationPage.Resources. And then change the Fill of Grid into Red.
Now the problem is that, when I open this app in simulator, the LoopingSelector does not show up immediately. But as soon as I touch the screen area where the selector should be, it shows up and the border color is what I want. This looks like an initialization problem, but I do not know what to do. I try to copy this style definition without any change from the original Generic.xaml, the problem still exists. Any one can help me with this problem?
<phone:PhoneApplicationPage.Resources>
<Style TargetType="primitives:LoopingSelectorItem">
<Setter Property="Foreground" Value="{StaticResource PhoneSubtleBrush}"/>
<Setter Property="Padding" Value="6"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border x:Name="root" CacheMode="BitmapCache" Background="Transparent" Padding="{TemplateBinding Padding}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<VisualTransition From="Normal" To="Expanded" GeneratedDuration="0:0:0.33" />
<VisualTransition From="Expanded" To="Normal" GeneratedDuration="0:0:0.33" />
</VisualStateGroup.Transitions>
<VisualState x:Name="Normal" />
<VisualState x:Name="Expanded">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="border" Storyboard.TargetProperty="Opacity" To="0.8" Duration="0"/>
</Storyboard>
</VisualState>
<VisualState x:Name="Selected">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="background" Storyboard.TargetProperty="Opacity" To="1" Duration="0"/>
<DoubleAnimation Storyboard.TargetName="border" Storyboard.TargetProperty="Opacity" To="1" Duration="0"/>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="border" Storyboard.TargetProperty="BorderBrush" Duration="0">
<ObjectAnimationUsingKeyFrames.KeyFrames>
<DiscreteObjectKeyFrame KeyTime="0" Value="Transparent" />
</ObjectAnimationUsingKeyFrames.KeyFrames>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="contentControl" Storyboard.TargetProperty="Foreground" Duration="0">
<ObjectAnimationUsingKeyFrames.KeyFrames>
<DiscreteObjectKeyFrame KeyTime="0" Value="White" />
</ObjectAnimationUsingKeyFrames.KeyFrames>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border.RenderTransform>
<TranslateTransform x:Name="Transform"/>
</Border.RenderTransform>
<Grid>
<Rectangle x:Name="background" Margin="0" Opacity="0" Fill="Red" CacheMode="BitmapCache"/>
<Border x:Name="border" Opacity="0" BorderThickness="3" BorderBrush="{StaticResource PhoneSubtleBrush}">
<ContentControl x:Name="contentControl" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch">
<ContentPresenter x:Name="contentPresenter" CacheMode="BitmapCache"/>
</ContentControl>
</Border>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</phone:PhoneApplicationPage.Resources>
I've just found myself having this exact same problem. The way I got round it was by taking the LoopingSelector and LoopingSelectorItem code from the Toolkit's source, rename them to CustomLoopingSelector and CustomLoopingSelectorItem. Then in my generic.xaml, but the Toolkit's default style for the LoopingSelector, but then add the style I wanted for the LoopingSelectorItem as the CustomLoopingSelectorItem's default style.
This has now given me the style I want, and doesn't blank out when coming back into the page. Might be worth a try for you.
I'm new to WinRT/XAML dev. After hours of research on the net and many trial and error attempts, I am still unable to understand how to use the VisualStateManager to change the fill color of an ellipse based on user input over the object. The following code does not work. Here is the code as it sits today:
<Ellipse Stroke="White" StrokeThickness="5" Width="90" Height="90">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver">
<Storyboard>
<ColorAnimation To="Red" Storyboard.TargetName="Ellipse" Storyboard.TargetProperty="Fill.Color"/>
</Storyboard>
</VisualState>
<VisualStateGroup.Transitions>
<VisualTransition To="Normal" GeneratedDuration="00:00:01"/>
<VisualTransition To="MouseOver" GeneratedDuration="00:00:01"/>
</VisualStateGroup.Transitions>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Ellipse>
UPDATE:
Thank you Nicholas W. for the nudge in the right direction. I was missing the template as well as the correct target property. The following code is working as intended:
<Button>
<Button.Template>
<ControlTemplate>
<Grid>
<Ellipse x:Name="myEllipse" Stroke="White" StrokeThickness="5" Width="70" Height="70" Fill="Transparent"/>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="Pressed">
<Storyboard>
<ColorAnimation Storyboard.TargetName="myEllipse" To="#FF0061D4" Storyboard.TargetProperty="(Rectangle.Fill).(SolidColorBrush.Color)" Duration="0:0:0"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>
There are a few problems here, firstly there is nothing causing the visual state manager to transition between states, secondly the reference to the "Ellipse" target is not resolved, and thirdly there is no brush defined on which to perform the color animation. If you were to retemplate a control which is already using visual states, the first part would be done for you, otherwise you need to set up explicit state transitions (example). To enable the reference to work, you can give the element a name, and don't nest the VisualStateGroups attached property in the element itself (or animate by name of the brush as per the MSDN example). And the last part just involves setting up a brush initially, on which you animate the Color property. Together, with the example of retemplating a Button:
<Button>
<Button.Template>
<ControlTemplate>
<Grid>
<Ellipse x:Name="Ellipse" Stroke="White" StrokeThickness="5" Width="90" Height="90"
Fill="Black"/>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver">
<Storyboard>
<ColorAnimation Storyboard.TargetName="Ellipse" To="Red" Storyboard.TargetProperty="Fill.Color"/>
</Storyboard>
</VisualState>
<VisualStateGroup.Transitions>
<VisualTransition To="Normal" GeneratedDuration="00:00:01"/>
<VisualTransition To="MouseOver" GeneratedDuration="00:00:01"/>
</VisualStateGroup.Transitions>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>
I have been creating a menu which when you click a button it slides out and click it again it slides in. A bit like the way the android menu system works, although you dont drag this you just click it.
So I was wondering how do you hide an element off screen? I have tried setting the global offset, but depending on the screen resolution I can still see rectangles and circles which should be hidden. I did get it to work using margins, but it meant i would have huge margins to hide elements, just didnt seem correct. I cant use visibility, because i need to animate the menu coming in from below the button. I have been using expression blend 4.
Any help would be great?
Well I solved one of the problems. I managed to hide the components off screen by aligning them to the bottom or to the left and then changing the render transform value to hide them off screen. My new problem is when i click the eclipse button a rectangle should fill the whole background but it only fills a portion off it.
Hi, thanks for the reply Joel, I actually found that by setting the width and height of the design view worked. But on different resolutions i could see this not working. My code for this is...
Xaml:
<UserControl.Resources>
<Style x:Key="ButtonStyle1" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver"/>
<VisualState x:Name="Pressed"/>
<VisualState x:Name="Disabled"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Ellipse x:Name="ellipse" Fill="#FF8D5216" Stroke="Black"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid Margin="0" Background="Transparent" Height="384" VerticalAlignment="Bottom">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="VisualStateGroup">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0:0:0.3"/>
</VisualStateGroup.Transitions>
<VisualState x:Name="Move">
<Storyboard>
<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="grid" d:IsOptimized="True"/>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="BlackBoarder">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Thickness>0</Thickness>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<DoubleAnimation Duration="0" To="20" Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="BaseBoarder" d:IsOptimized="True"/>
</Storyboard>
</VisualState>
<VisualState x:Name="Down"/>
<VisualState x:Name="SlideAcross"/>
<VisualState x:Name="SlideBack"/>
<VisualState x:Name="FlipForward">
<Storyboard>
<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="BlackBoarder" d:IsOptimized="True"/>
<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="BlackBoarder" d:IsOptimized="True"/>
<DoubleAnimation Duration="0" To="180" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)" Storyboard.TargetName="BlackBoarder" d:IsOptimized="True"/>
<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="grid" d:IsOptimized="True"/>
<DoubleAnimation Duration="0" To="180" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="grid" d:IsOptimized="True"/>
<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)" Storyboard.TargetName="grid" d:IsOptimized="True"/>
</Storyboard>
</VisualState>
<VisualState x:Name="FlipBack">
<Storyboard>
<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="BlackBoarder" d:IsOptimized="True"/>
<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="BlackBoarder" d:IsOptimized="True"/>
<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="grid" d:IsOptimized="True"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid x:Name="grid" Height="400" VerticalAlignment="Bottom" Background="Orange" RenderTransformOrigin="0.5,0.5" Margin="0,0,0,-21">
<Grid.Projection>
<PlaneProjection/>
</Grid.Projection>
<Grid.RenderTransform>
<CompositeTransform TranslateY="360"/>
</Grid.RenderTransform>
<Rectangle x:Name="MovingButtonTab" Fill="Black" Height="15" Margin="0,-14,0,0" Stroke="Black" VerticalAlignment="Top" HorizontalAlignment="Center" Width="250" MouseLeftButtonDown="ButtonTab_MouseLeftButtonDown"/>
<Rectangle x:Name="BlackBoarder" Fill="Gray" Margin="0" Stroke="Black" RenderTransformOrigin="0.5,0.5">
<Rectangle.Projection>
<PlaneProjection/>
</Rectangle.Projection>
<Rectangle.RenderTransform>
<CompositeTransform/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle x:Name="TitleRect" Fill="Black" Height="20" Margin="0" Stroke="Black" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" />
<sdk:Label Height="20" Margin="0" Width="219" Content="" Background="Orange" Foreground="White" VerticalAlignment="Top" HorizontalAlignment="Center" RenderTransformOrigin="0.5,0.5"/>
</Grid>
<Rectangle x:Name="BaseBoarder" Fill="Gray" Height="20" Stroke="Black" VerticalAlignment="Bottom"/>
So i'm guessing on the main parent grid view I should add the xaml:
<RectangleGeometry Rect="0,0,640,480" />
And just adjust the numbers to the desired size? Would this still have the same problem of not working on all resolutions though?
Also, my control that I have created isn't transparent, even though i have set the parent grid to "transparent" it still has a "white" background. Basically it fills the screen by the height that the menu bar can reach even before the user clicks on it. Is there away round this?
I solved the solution of the white background. Using RenderTransform to move the object off the viewing area in the "Base" state seems to cause the issue. Using margins, actually solves the issue. I can't tell you why though... I just tried it out and it worked.
Thanks Again
In Silverlight, you need to add a Clipping Region to your base container.
<Grid>
<Grid.Clip>
<RectangleGeometry Rect="0,0,640,480" />
</Grid.Clip>
// other content
</Grid>
You'll need to modify the Rect paramteres or add some binding to match your application.
One caveat: Blend respects the Clipping Region, so once you add it you won't be able to see the elements that are drawn "offscreen" anymore.
I have a tabcontrol in mainpage. I want to add close button to header template of tab items. How can i add header template to tabitems in c# code. please help..
See It : type this codes in resources of UserControl
<Style TargetType='sdk:TabItem'>
<Setter Property='HeaderTemplate'>
<Setter.Value>
<DataTemplate>
<StackPanel Orientation='Horizontal'
Background='Transparent'>
<TextBlock Text='{Binding}' />
<!--<Button Command="{Binding RemoveItemCommand}" VerticalAlignment='Center'
Style="{StaticResource CloseButton}"
Margin="5,0,0,0"
Content="M0,0 L6,6 M6, 0 L0,6"
ToolTipService.ToolTip="Remove item" />-->
<Button x:Name='btnCloaseTab'
Click='btnCloaseTab_Click'
VerticalAlignment='Center'
Style="{StaticResource CloseButton}"
Margin="5,0,0,0"
Content="M0,0 L6,6 M6, 0 L0,6"
ToolTipService.ToolTip="بستن زبانه" />
</StackPanel>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
Have a look at the following link, it explains how to customize the tab control to add more in the tab itself. I would add a image button to the tab header and the associate a click event to close it.
http://www.c-sharpcorner.com/UploadFile/mahesh/SilverlightTabControl07022008170702PM/SilverlightTabControl.aspx
Here is a sample
<Grid x:Name="LayoutRoot" Background="White">
<sdk:TabControl Height="100" HorizontalAlignment="Left" Margin="108,94,0,0" Name="tabControl1" VerticalAlignment="Top" Width="200">
<sdk:TabItem Name="tabItem1">
<sdk:TabItem.Header>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Polygon" Margin="1,1,1,1" VerticalAlignment="Center" />
<Button Content="X" Click="Button_Click"/>
</StackPanel>
</sdk:TabItem.Header>
<Grid />
</sdk:TabItem>
</sdk:TabControl>
</Grid>
<Style x:Key="CloseButton"
TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid Background="Transparent"
Width="14"
Height="14">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
Storyboard.TargetName="FocusEllipse">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ColorAnimation Duration="0"
To="#FFDC3030"
Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
Storyboard.TargetName="FocusEllipse" />
<ColorAnimation Duration="0"
To="White"
Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)"
Storyboard.TargetName="path" />
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
Storyboard.TargetName="FocusEllipse">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ColorAnimation Duration="0"
To="Black"
Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
Storyboard.TargetName="FocusEllipse" />
<ColorAnimation Duration="0"
To="White"
Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)"
Storyboard.TargetName="path" />
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled" />
</VisualStateGroup>
<VisualStateGroup x:Name="FocusStates">
<VisualState x:Name="Focused" />
<VisualState x:Name="Unfocused" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Ellipse x:Name="FocusEllipse"
Fill="#FFF13535"
Visibility="Collapsed" />
<Path x:Name="path"
Data="{TemplateBinding Content}"
Stroke="#FF898888"
HorizontalAlignment="Center"
VerticalAlignment="Center"
StrokeThickness="1" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>