WPF 使用触发器让窗口无法最大化且同时可以调整窗口大小
示例代码:
<Window.Style> <Style TargetType="{x:Type Window}"> <Setter Property="WindowState" Value="{Binding Tag, RelativeSource={RelativeSource Mode=Self}, UpdateSourceTrigger=PropertyChanged,Delay=100}"/> <Style.Triggers> <Trigger Property="WindowState" Value="Maximized"> <Trigger.EnterActions> <BeginStoryboard x:Name="bs"> <Storyboard Storyboard.TargetProperty="Tag" Duration="0:0:0" > <ObjectAnimationUsingKeyFrames> <DiscreteObjectKeyFrame KeyTime="0:0:0"> <DiscreteObjectKeyFrame.Value> <WindowState>normal</WindowState> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> </Storyboard> </BeginStoryboard> </Trigger.EnterActions> <Trigger.ExitActions> <RemoveStoryboard BeginStoryboardName="bs"/> </Trigger.ExitActions> </Trigger> </Style.Triggers> </Style> </Window.Style>