views:

26

answers:

0

So here's the situation, I have a control (code below) that plays an animation from a style datatrigger when a viewmodel property is equal to a value (Binding="{Binding OperatorState}" Value="Blah")

Trouble is, although I can bind the BINDING I can't bind the value, as Value appears to have to be a literal. I wanted to do something like bind Value to Grid's "Tag" property, but that throws a compiler error.

What would be the proper way to handle this scenario? a different kind of template binding? control template instead of style template? then I lose my datatriggers, what would I use instead? I'd really like a longer explanation of why my method is "wrong" (presuming i'm going about this the wrong way) and why your method is "right".

<Grid RenderTransformOrigin="0.5,0.5" VerticalAlignment="Center">
    <Grid.Style>
     <Style>
      <Style.Triggers>
       <DataTrigger Binding="{Binding OperatorState}" Value="Blah">
        <DataTrigger.EnterActions>
         <BeginStoryboard>
          <Storyboard Duration="00:00:01.0">
           <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
            <SplineDoubleKeyFrame KeyTime="00:00:01.0" Value="1.4" KeySpline="0,0,0,1"/>
           </DoubleAnimationUsingKeyFrames>
           <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
            <SplineDoubleKeyFrame KeyTime="00:00:01.0" Value="1.4" KeySpline="0,0,0,1"/>
           </DoubleAnimationUsingKeyFrames>
          </Storyboard>
         </BeginStoryboard>
        </DataTrigger.EnterActions>
        <DataTrigger.ExitActions>
         <BeginStoryboard>
          <Storyboard Duration="00:00:01.0">
           <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
            <SplineDoubleKeyFrame KeyTime="00:00:01.0" Value="1.0" KeySpline="0,0,0,1"/>
           </DoubleAnimationUsingKeyFrames>
           <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
            <SplineDoubleKeyFrame KeyTime="00:00:01.0" Value="1.0" KeySpline="0,0,0,1"/>
           </DoubleAnimationUsingKeyFrames>
          </Storyboard>
         </BeginStoryboard>
        </DataTrigger.ExitActions>
       </DataTrigger>
      </Style.Triggers>
     </Style>
    </Grid.Style>
    <bl:GlassBorder Background="#FF62A958" BorderBrush="#FF1A5F5B" BorderThickness="0,2" GlassOpacity="0.8" Content="Blah?" RenderTransformOrigin="0.5,0.5"/>
</Grid>