有没有办法采取这个多关联:
<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的资源:
原文链接:https://www.f2er.com/xml/292325.html<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>