0

任何人都可以帮助我还是我错过了什么?视觉状态未触发

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>
4

1 回答 1

2

假设您的意思是 CellTemplate 上的状态使用 DataTriggers on Urgency,我认为您需要更改 GoToStateActions 上的Target属性

TargetName 的默认值是根范围,例如您的 UserControl 或 Window。

您希望目标是单元格。

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

于 2010-04-12T17:29:24.590 回答