Hi all,
I'm loving behaviours and states in Blend 3. Typically I'm using the
GoToStateAction behaviour to go to a state when an action occurs.
I've hit a snag with ControlTemplate triggers though. Blend lets me
define states in the ControlTemplate, but I can't work out how to assign
the behaviour to use them.
Here's my scenario: I've created a Style for a RadioButton with a
ControlTemplate that contains two Borders (called "Checked" and
"Unchecked") wrapped in a grid. Previously I've used a
ControlTemplate.Trigger on IsChecked = True to change the opacity of the
borders to display the relevant visual. I now want to use state
transitions to provide an easing between the two states.
In the ControlTemplate I can create the states IsChecked and IsUnchecked
(in a state group called "ChangeCheckState") as normal. However, there'
s nowhere to drag the GoToStateAction to the ControlTemplate.Trigger.
Obviously this is doing it wrong.
My only option at this stage is to define my own storyboards to activate
when the IsChecked trigger occurs. I really want to just let the state
transition handle it for me instead though, because it's a lot easier to
use than getting up to my elbows in storyboard maintenance.
Is there any way to use behaviors to perform the easing for me in this
situation?
Here's some code:
<Style x:Key="MyRadioButton" TargetType="{x:Type RadioButton}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RadioButton}" >
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup
x:Name="ChangeCheckState">
<VisualStateGroup.Transitions>
<VisualTransition
GeneratedDuration="00:00:00.2000000"/>
</VisualStateGroup.Transitions>
<VisualState
x:Name="IsChecked">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Duration="00:00:00.0010000" Storyboard.TargetName="Checked"
Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Duration="00:00:00.0010000" Storyboard.TargetName="Unchecked"
Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState
x:Name="IsUnchecked"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border x:Name="Checked" Opacity="0" >
<!--Content-->
</Border>
<Border x:Name="Unchecked">
<!--Content-->
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked"
Value="True">
<Setter TargetName="Checked"
Property="Opacity" Value="1" />
<Setter TargetName="Unchecked"
Property="Opacity" Value="0" />
</Trigger>
<Trigger Property="IsChecked"
Value="False">
<Setter TargetName="Checked"
Property="Opacity" Value="0" />
<Setter TargetName="Unchecked"
Property="Opacity" Value="1" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Cheers,
Carl.
Carl Scarlett
Senior .NET/WPF Developer - Genesis Team
IT Applications Delivery | bankwest
A: Level 5, 199 Hay Street | Perth | Western Australia | 6004
P: (08) 9449 8703
M: 0408 913 870
E: [email protected]
_______________________________________________________________________________
Unencrypted electronic mail is not secure and may not be authentic.
If you have any doubts as to the contents please telephone to confirm.
This electronic transmission including any attachments is intended only
for those to whom it is addressed. It may contain copyright material or
information that is confidential, privileged or exempt from disclosure by law.
Any claim to privilege is not waived or lost by reason of mistaken transmission
of this information. If you are not the intended recipient you must not
distribute or copy this transmission and should please notify the sender.
Your costs for doing this will be reimbursed by the sender.
We do not accept liability in connection with computer virus, data corruption,
delay, interruption, unauthorised access or unauthorised amendment.
_______________________________________________________________________________
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
_____________________________________________________________________________________________________________________
ozsilverlight mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight