Część domyślna Template
dla klasy Window
to AdornerDecorator
. Jeśli zastąpisz domyślną wartość Template
, aby nie zawierała ona wartości AdornerDecorator
, wszystkie elementy sterujące nie będą wyświetlane na wszystkich elementach sterujących FocusVisualStyle
.
Nawet jeśli Control
posiada ważne FocusVisualStyle
który wyznacza Template
, że nie pojawią się bez AdornerDecorator
.
Łatwym sposobem na osiągnięcie tego jest dołączenie tego Style
do pliku App.xaml pod numerem Application.Resources
.
<Style TargetType="{x:Type Window}">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Window}">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
<ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="ResizeMode" Value="CanResizeWithGrip">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Window}">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
<Grid>
<ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}"/>
<ResizeGrip x:Name="WindowResizeGrip" HorizontalAlignment="Right" IsTabStop="False" Visibility="Collapsed" VerticalAlignment="Bottom"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="ResizeMode" Value="CanResizeWithGrip"/>
<Condition Property="WindowState" Value="Normal"/>
</MultiTrigger.Conditions>
<Setter Property="Visibility" TargetName="WindowResizeGrip" Value="Visible"/>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
Dlaczego to uzyskać -1? –
Prawdopodobnie dlatego, że jest niepotrzebnie skomplikowany, obarczony trudnościami, takimi jak zapewnienie, że pokryłeś każdy możliwy przypadek krawędzi i jest dość trudny w utrzymaniu, by wymienić 2. W porównaniu z 'Stylem' i' Seterem' dla każdego typu (który, chociaż nużący, jest prosty), twoja sugestia brzmi szalenie. Nie dałem -1. –
Ponieważ nie skomentował, że któreś z rozwiązań będzie działało, nie wiemy, czy pomogły inne pomysły. Jeśli jest to jedyna idea, która spełnia jego potrzeby, "obłąkany" byłby niedokładnym opisem. –