WPF:如何在Trigger里修改Orientation?
<Style TargetType={x:Type TabControl}>
...
<WrapPanel x:Name="myPanel" ...
...
<Trigger>
<Setter TargetName="myPanel" Property="Orientation" ...
</Trigger>
...
...
...
</Style>
如何在Trigger里修改Orientation?我想让Orientaion在某些Trigger下使用不同的布局方向
回答
代码如下,需要注意的是,默认WrapPanel的orientation属性要写在style里,写在WrapPanel特性中的属性是本地值,无法通过trigger改变
<WrapPanel> <WrapPanel.Style>
<Style TargetType="WrapPanel">
<Setter Property="Orientation" Value="Horizontal"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" Value="Red"/>
<Setter Property="Orientation" Value="Vertical"/>
</Trigger>
</Style.Triggers>
</Style>
</WrapPanel.Style>
<Button Content="button1" Margin="10"/>
<Button Content="button1" Margin="10"/>
</WrapPanel>
以上是 WPF:如何在Trigger里修改Orientation? 的全部内容, 来源链接: www.h5w3.com/114123.html