xaml – WinRT中的DataTrigger?

前端之家收集整理的这篇文章主要介绍了xaml – WinRT中的DataTrigger?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我可以在WinRT参考中找到 EventTrigger,但是我找不到DataTrigger。我也无法在应用程序中使用它。

任何人都可以确认DataTrigger在WinRT中真的丢失了吗? EventTrigger是WinRT中唯一可用的触发器吗?

我不知道什么时候改变,但我有DataTriggerBehavior和GoToStateAction组合他们应该解决你的问题…

命名空间导入

xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" 
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
xmlns:Interactivity="using:Microsoft.Xaml.Interactivity" 
xmlns:Core="using:Microsoft.Xaml.Interactions.Core"

ViewSateManager放在根元素上

<VisualStateManager.VisualStateGroups>
    <VisualStateGroup x:Name="Common">
        <VisualStateGroup.Transitions>
            <VisualTransition GeneratedDuration="0" To="Online">
                <Storyboard>
                    <ColorAnimation Duration="0" To="Lime" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="Name" />
                </Storyboard>
            </VisualTransition>
            <VisualTransition GeneratedDuration="0" To="Offline">
                <Storyboard>
                    <ColorAnimation Duration="0" To="Red" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="Name" />
                </Storyboard>
            </VisualTransition>
        </VisualStateGroup.Transitions>
        <VisualState x:Name="Online" />
        <VisualState x:Name="Offline" />
    </VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Interactivity:Interaction.Behaviors>
    <Core:DataTriggerBehavior Binding="{Binding Active}" Value="True">
        <Core:GoToStateAction StateName="Online" />
    </Core:DataTriggerBehavior>
    <Core:DataTriggerBehavior Binding="{Binding Active}" Value="False">
        <Core:GoToStateAction StateName="Offline" />
    </Core:DataTriggerBehavior>
</Interactivity:Interaction.Behaviors>
原文链接:https://www.f2er.com/windows/372834.html

猜你在找的Windows相关文章