问题描述
我为 Windows 制作了一个全新的样式,删除了基本样式以删除基本标题栏和所有内容。整个过程运行良好,关闭按钮重新实现,但我有一点用户体验问题。
当我覆盖基本样式时,我在打开和关闭时丢失了默认的淡入和淡出动画,我想恢复。
然后我通过 Style Snooper 搜索了 Window 上使用的基本样式,但我找不到任何看起来像故事板之类的东西。
我覆盖基本样式的方式:
<Style x:Key="WindowStyle" targettype="Window">
<Setter Property="Background" Value="Gray" />
</Style>
<Style x:Key="ModalWindowStyle" targettype="Window" BasedOn="{StaticResource WindowStyle}">
<Setter Property="WindowStyle" Value="None"/>
<Setter Property="AllowsTransparency" Value="True"/>
<Setter Property="SizetoContent" Value="WidthAndHeight"/>
</Style>
我通过 Style snooper 发现的 Style:
<Style targettype="{x:Type Window}" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style.Triggers>
<Trigger Property="Window.ResizeMode">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate targettype="{x:Type Window}">
<Border BorderThickness="{TemplateBinding Border.BorderThickness}" BorderBrush="{TemplateBinding Border.BorderBrush}" Background="{TemplateBinding Panel.Background}">
<Grid>
<AdornerDecorator>
<ContentPresenter Content="{TemplateBinding ContentControl.Content}" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}" />
</AdornerDecorator>
<Resizegrip IsTabStop="False" Name="WindowResizegrip" HorizontalAlignment="Right" VerticalAlignment="Bottom" Visibility="Collapsed" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Window.ResizeMode" Value="{x:Static ResizeMode.CanResizeWithgrip}" />
<Condition Property="Window.WindowState" Value="{x:Static WindowState.normal}" />
</MultiTrigger.Conditions>
<Setter Property="UIElement.Visibility" TargetName="WindowResizegrip">
<Setter.Value>
<x:Static Member="Visibility.Visible" />
</Setter.Value>
</Setter>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Trigger.Value>
<x:Static Member="ResizeMode.CanResizeWithgrip" />
</Trigger.Value>
</Trigger>
</Style.Triggers>
<Style.Resources>
<ResourceDictionary />
</Style.Resources>
<Setter Property="TextElement.Foreground">
<Setter.Value>
<DynamicResource ResourceKey="{x:Static SystemColors.WindowTextBrushKey}" />
</Setter.Value>
</Setter>
<Setter Property="Panel.Background">
<Setter.Value>
<DynamicResource ResourceKey="{x:Static SystemColors.WindowBrushKey}" />
</Setter.Value>
</Setter>
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate targettype="{x:Type Window}">
<Border BorderThickness="{TemplateBinding Border.BorderThickness}" BorderBrush="{TemplateBinding Border.BorderBrush}" Background="{TemplateBinding Panel.Background}">
<AdornerDecorator>
<ContentPresenter Content="{TemplateBinding ContentControl.Content}" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}" />
</AdornerDecorator>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
如果有人能引导我重新实现完全相同的动画(也许它在某处定义,我可以使用它)或在 WPF 本身中执行此操作的一段代码,我将非常感激:)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)