Silverlight 4.0 视觉状态管理器

发布于 2024-08-28 17:03:14 字数 3181 浏览 8 评论 0原文

谁能帮助我或者我错过了什么吗?视觉状态未触发

xmlns:swi="clr-namespace:System.Windows.Interactivity; assembly=System.Windows.Interactivity" xmlns:esi =“clr命名空间:Expression.Samples.Interactivity;程序集=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>

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千仐 2024-09-04 17:03:14

假设您的意思是使用紧急情况下的 DataTriggers 来表示 CellTemplate 上的状态,我认为您需要更改 GoToStateActions 上的 Target 属性

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

您希望目标是单元格。

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文