GoToStateAction带来麻烦

| 在不同的情况下,我对GoToStateAction遇到了一些问题,并且我开始相信该功能存在错误,或者我对该功能的了解已关闭。 在这种情况下,我有一个带有表示连接器的椭圆的数据模板。连接器具有IsConnected属性...我正在使用VisualStates和带有DataTrigger的GoToStateAction在2个状态\'Connected \'和\'NotConnected \'之间切换。但是,在这种情况下,永远不会设置状态。 我知道模型设置正确,因为尝试使用IsConnected的其他绑定方案效果很好。我究竟做错了什么?
<DataTemplate x:Key=\"ConnectorTemplate\">
            <Grid x:Name=\"grid\">
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name=\"ConnectionStates\">
                        <VisualState x:Name=\"Connected\">
                            <Storyboard>
                                <ColorAnimation Duration=\"0\" To=\"#FFEAFFDD\" Storyboard.TargetProperty=\"(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)\" Storyboard.TargetName=\"ellipse\" d:IsOptimized=\"True\"/>
                                <ColorAnimation Duration=\"0\" To=\"#FF56992B\" Storyboard.TargetProperty=\"(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)\" Storyboard.TargetName=\"ellipse\" d:IsOptimized=\"True\"/>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name=\"NotConnected\"/>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <VisualStateManager.CustomVisualStateManager>
                    <ei:ExtendedVisualStateManager/>
                </VisualStateManager.CustomVisualStateManager>

                <Ellipse x:Name=\"ellipse\"
                    Height=\"8\"
                    Width=\"8\">
                    <i:Interaction.Triggers>
                        <ei:DataTrigger Binding=\"{Binding IsConnected}\" Value=\"true\">
                            <ei:GoToStateAction StateName=\"Connected\"/>
                        </ei:DataTrigger>
                        <ei:DataTrigger Binding=\"{Binding IsConnected}\" Value=\"false\">
                            <ei:GoToStateAction StateName=\"NotConnected\"/>
                        </ei:DataTrigger>
                    </i:Interaction.Triggers>
                    <Ellipse.Fill>
                        <RadialGradientBrush Center=\"0.275,0.262\"
                            GradientOrigin=\"0.275,0.262\"
                            RadiusX=\"0.566\"
                            RadiusY=\"0.566\">
                            <GradientStop Color=\"#FF333333\"
                                Offset=\"1\" />
                            <GradientStop Color=\"#FFC4C4C4\" />
                        </RadialGradientBrush>
                    </Ellipse.Fill>
                </Ellipse>
            </Grid>
        </DataTemplate>
    
已邀请:
我认为您应该在GoToStateAction中设置TargetName,因为默认情况下,如果我的记忆正确,Target与GoToStateAction对象相关联,在您的情况下-椭圆     
加载项目时不会触发GoToStateAction,它仅在更改相关属性(激发PropertyChanged事件)时才起作用。     

要回复问题请先登录注册