winrt-xaml – 禁用时更改Button的样式(IsEnabled = False)
发布时间:2020-12-14 02:14:04 所属栏目:Windows 来源:网络整理
导读:我有一个UWP问题.如何禁用按钮的样式(IsEnabled = False)? 解决方法 这是你如何做到的. StackPanel Button x:Name="button" Content="Click Me" IsEnabled="{Binding IsChecked,ElementName=checkBox}" Interactivity:Interaction.Behaviors Core:DataTrigg
我有一个UWP问题.如何禁用按钮的样式(IsEnabled = False)?
解决方法
这是你如何做到的.
<StackPanel> <Button x:Name="button" Content="Click Me" IsEnabled="{Binding IsChecked,ElementName=checkBox}"> <Interactivity:Interaction.Behaviors> <Core:DataTriggerBehavior Binding="{Binding IsEnabled,ElementName=button,Mode=OneWay}" Value="True"> <Core:ChangePropertyAction PropertyName="Opacity" Value="1"/> </Core:DataTriggerBehavior> <Core:DataTriggerBehavior Binding="{Binding IsEnabled,Mode=OneWay}" Value="False"> <Core:ChangePropertyAction PropertyName="Opacity" Value=".5"/> </Core:DataTriggerBehavior> </Interactivity:Interaction.Behaviors> </Button> <CheckBox x:Name="checkBox" IsChecked="True" /> </StackPanel> 不要忘记您需要引用Behaviors SDK. 祝你好运! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |