views:

554

answers:

1

Can anyone please help me or is there anything I miss out? the visualstate is not triggered

xmlns:swi="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:esi="clr-namespace:Expression.Samples.Interactivity;assembly=Expression.Samples.Interactivity" xmlns:mei="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"

<my:DataGridTemplateColumn IsReadOnly="True">
                <my:DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                        <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="vsgUrgency">
                                    <VisualState x:Name="UrgencySerious">
                                        <Storyboard>
                                            <ColorAnimation Storyboard.TargetName="orbUrgency"
                                        Storyboard.TargetProperty="Fill" To="Red"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="UrgencyNormal">
                                        <Storyboard>
                                            <ColorAnimation Storyboard.TargetName="orbUrgency"
                                        Storyboard.TargetProperty="Fill" To="Green"/>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>    
                            <swi:Interaction.Triggers>
                                <esi:DataTrigger Binding="{Binding Urgency}" Value="Serious">
                                    <mei:GoToStateAction StateName="UrgencySerious"/>
                                </esi:DataTrigger>
                                <esi:DataTrigger Binding="{Binding Urgency}" Value="Normal">
                                    <mei:GoToStateAction StateName="UrgencyNormal"/>
                                </esi:DataTrigger>
                            </swi:Interaction.Triggers>
                            <TextBlock Text="{Binding Urgency}"/>
                            <Path x:Name="orbUrgency" Width="14.6566" Height="14.5449" Stretch="Fill" StrokeThickness="1" 
                            StrokeLineJoin="Round" Fill="#FFE50A0A" 
                            Data="F1 M 9.3269,3.61737C 13.3742,3.61737 16.6552,6.87332 16.6552,10.8898C 16.6552,14.9063 13.3742,18.1623 9.3269,18.1623C 5.2796,18.1623 1.99862,14.9063 1.99862,10.8898C 1.99862,6.87332 5.27956,3.61737 9.3269,3.61737 Z ">
                            </Path>
                        </StackPanel>
                    </DataTemplate>
                </my:DataGridTemplateColumn.CellTemplate>
            </my:DataGridTemplateColumn>
+1  A: 

Assuming you mean the states on the CellTemplate using the DataTriggers on Urgency, I think you need to change the Target property on the GoToStateActions

the default value for TargetName is the root scope such as your UserControl or Window.

You want the Target to be the Cell.

http://blogs.msdn.com/expression/archive/2010/02/22/switching-visual-states-easily-using-gotostateaction.aspx

Bobby