wpf – 在xaml中的单行上放置多线
发布时间:2020-12-16 07:44:15 所属栏目:百科 来源:网络整理
导读:有没有办法采取这个多关联: TextBox.IsEnabled MultiBinding Converter="{StaticResource LogicConverter}" Binding ElementName="prog0_used" Path="IsEnabled" / Binding ElementName="prog0_used" Path="IsChecked" / /MultiBinding/TextBox.IsEnabled
有没有办法采取这个多关联:
<TextBox.IsEnabled> <MultiBinding Converter="{StaticResource LogicConverter}"> <Binding ElementName="prog0_used" Path="IsEnabled" /> <Binding ElementName="prog0_used" Path="IsChecked" /> </MultiBinding> </TextBox.IsEnabled> 和put全部在一行,如< TextBox IsEnabled =“”/>? 如果是这样,在哪里可以学习这个formattiong的规则?
更好(更简单)的方法是将样式定义为可以轻松应用于任何TextBox的资源:
<Window.Resources> <c:MyLogicConverter x:Key="LogicConverter" /> <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}" x:Key="MultiBound"> <Setter Property="IsEnabled"> <Setter.Value> <MultiBinding Converter="{StaticResource LogicConverter}"> <Binding ElementName="switch" Path="IsEnabled" /> <Binding ElementName="switch" Path="IsChecked" /> </MultiBinding> </Setter.Value> </Setter> </Style> </Window.Resources> <StackPanel Orientation="Horizontal"> <CheckBox Name="switch" /> <TextBox Name="textBox2" Text="Test" Style="{StaticResource MultiBound}" /> </StackPanel> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |