Wpf 如何通过触发器更改WrapPanel的方向属性?
我想知道如何通过触发器更改WrapPanel方向属性 我使用触发器更改“包裹面板方向”属性,但它不起作用Wpf 如何通过触发器更改WrapPanel的方向属性?,wpf,xaml,triggers,orientation,Wpf,Xaml,Triggers,Orientation,我想知道如何通过触发器更改WrapPanel方向属性 我使用触发器更改“包裹面板方向”属性,但它不起作用 <WrapPanel Orientation="Horizontal"> <WrapPanel.Style> <Style TargetType="WrapPanel"> <Style.Triggers> <Trigger Property="IsMouseO
<WrapPanel Orientation="Horizontal">
<WrapPanel.Style>
<Style TargetType="WrapPanel">
<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="button2" Margin="10"/>
</WrapPanel>
我希望按钮是垂直的,背景是红色的,但结果是水平按钮和红色背景。背景已向右更改,但方向未更改。通过样式设置器设置默认方向值
Orientation=“Horizontal”
是一个本地值,不能由样式触发器重置
<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="button2" Margin="10"/>
</WrapPanel>