如何在 UWP 应用程序中通过触发器更改 属性

How to Change Property by Trigger in UWP app

当 Text 属性 在 wpf 中为 null 或为空时,我想更改 TextBlock 的可见性我们可以轻松地做到这一点:

<Style TargetType = "TextBlock"> 
         <Setter Property = "Visibility" Value = "Visibile" /> 
         <Style.Triggers> 
            <Trigger Property = "Text" Value = ""> 
               <Setter Property = "Visibility" Value = "Collapsed" /> 
            </Trigger> 
         </Style.Triggers> 
      </Style> 

但触发器在 uwp 中不可用,我如何在 uwp 中执行此操作?

 <Interactivity:Interaction.Behaviors>
    <Core:DataTriggerBehavior Binding="{Binding Text, ElementName=txt}" ComparisonCondition="Equal" Value="">
        <Core:ChangePropertyAction TargetObject="{Binding ElementName=txt}" PropertyName="Visibility" Value="Collapsed" />
    </Core:DataTriggerBehavior>
 </Interactivity:Interaction.Behaviors>