Browse Source

Tweaked TitleBar ControlTheme.

pull/8479/head
Steven Kirk 4 years ago
parent
commit
7fcd738369
  1. 15
      src/Avalonia.Controls/Chrome/TitleBar.cs
  2. 24
      src/Avalonia.Themes.Fluent/Controls/TitleBar.xaml

15
src/Avalonia.Controls/Chrome/TitleBar.cs

@ -35,7 +35,8 @@ namespace Avalonia.Controls.Chrome
}
}
IsVisible = window.PlatformImpl?.NeedsManagedDecorations ?? false;
if (!Design.IsDesignMode)
IsVisible = window.PlatformImpl?.NeedsManagedDecorations ?? false;
}
}
@ -44,13 +45,13 @@ namespace Avalonia.Controls.Chrome
base.OnApplyTemplate(e);
_captionButtons?.Detach();
_captionButtons = e.NameScope.Get<CaptionButtons>("PART_CaptionButtons");
if (VisualRoot is Window window)
if (VisualRoot is Window window && !Design.IsDesignMode)
{
_captionButtons?.Attach(window);
_captionButtons?.Attach(window);
UpdateSize(window);
}
}
@ -59,7 +60,7 @@ namespace Avalonia.Controls.Chrome
{
base.OnAttachedToVisualTree(e);
if (VisualRoot is Window window)
if (VisualRoot is Window window && !Design.IsDesignMode)
{
_disposables = new CompositeDisposable
{
@ -90,7 +91,7 @@ namespace Avalonia.Controls.Chrome
base.OnDetachedFromVisualTree(e);
_disposables?.Dispose();
_captionButtons?.Detach();
_captionButtons = null;
}

24
src/Avalonia.Themes.Fluent/Controls/TitleBar.xaml

@ -1,8 +1,8 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith>
<Border>
<TitleBar Background="SkyBlue" Height="30" Width="300" Foreground="Black" />
<Border Height="30" Width="300">
<TitleBar Background="SkyBlue" Foreground="Black" />
</Border>
</Design.PreviewWith>
@ -13,11 +13,19 @@
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template">
<ControlTemplate>
<Panel HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="Stretch">
<Panel x:Name="PART_MouseTracker" Height="1" VerticalAlignment="Top" />
<Panel HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="Stretch">
<Panel x:Name="PART_MouseTracker"
Height="1"
VerticalAlignment="Top" />
<Panel x:Name="PART_Container">
<Border x:Name="PART_Background" Background="{TemplateBinding Background}" />
<CaptionButtons x:Name="PART_CaptionButtons" VerticalAlignment="Top" HorizontalAlignment="Right" Foreground="{TemplateBinding Foreground}" />
<Border x:Name="PART_Background"
Background="{TemplateBinding Background}"
IsHitTestVisible="False"/>
<CaptionButtons x:Name="PART_CaptionButtons"
VerticalAlignment="Top"
HorizontalAlignment="Right"
Foreground="{TemplateBinding Foreground}" />
</Panel>
</Panel>
</ControlTemplate>
@ -27,10 +35,6 @@
<Setter Property="Background" Value="{DynamicResource SystemAccentColor}" />
</Style>
<Style Selector="^ /template/ Border#PART_Background">
<Setter Property="IsHitTestVisible" Value="False" />
</Style>
<Style Selector="^:fullscreen /template/ Border#PART_Background">
<Setter Property="IsHitTestVisible" Value="True" />
</Style>

Loading…
Cancel
Save