wpf – 在xaml中的单行上放置多线

前端之家收集整理的这篇文章主要介绍了wpf – 在xaml中的单行上放置多线前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
有没有办法采取这个多关联:
  1. <TextBox.IsEnabled>
  2. <MultiBinding Converter="{StaticResource LogicConverter}">
  3. <Binding ElementName="prog0_used" Path="IsEnabled" />
  4. <Binding ElementName="prog0_used" Path="IsChecked" />
  5. </MultiBinding>
  6. </TextBox.IsEnabled>

和put全部在一行,如< TextBox IsEnabled =“”/>?

如果是这样,在哪里可以学习这个formattiong的规则?

更好(更简单)的方法是将样式定义为可以轻松应用于任何TextBox的资源:
  1. <Window.Resources>
  2. <c:MyLogicConverter x:Key="LogicConverter" />
  3.  
  4. <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}" x:Key="MultiBound">
  5. <Setter Property="IsEnabled">
  6. <Setter.Value>
  7. <MultiBinding Converter="{StaticResource LogicConverter}">
  8. <Binding ElementName="switch" Path="IsEnabled" />
  9. <Binding ElementName="switch" Path="IsChecked" />
  10. </MultiBinding>
  11. </Setter.Value>
  12. </Setter>
  13. </Style>
  14. </Window.Resources>
  15.  
  16. <StackPanel Orientation="Horizontal">
  17. <CheckBox Name="switch" />
  18. <TextBox Name="textBox2" Text="Test" Style="{StaticResource MultiBound}" />
  19. </StackPanel>

猜你在找的XML相关文章