fix: fix toggle style.

This commit is contained in:
rabbitism 2023-02-13 03:29:56 +08:00
parent f3bb040dc9
commit 03e9056c82
3 changed files with 43 additions and 12 deletions

View File

@ -15,6 +15,7 @@
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceInclude Source="../Themes/ToggleButton.axaml" />
<ResourceInclude Source="../Controls/ColorItemControl.axaml" />
<ResourceInclude Source="../Controls/ColorDetailControl.axaml" />
<ResourceInclude Source="../Controls/FunctionalColorGroupControl.axaml" />
@ -34,18 +35,19 @@
Name="toggle"
HorizontalAlignment="Right"
IsChecked="True"
Theme="{DynamicResource BorderlessToggleButton}">
<PathIcon
Width="16"
Height="16"
Data="M5 2H19C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5C2 3.34315 3.34315 2 5 2ZM6 4C5.44772 4 5 4.44772 5 5V19C5 19.5523 5.44772 20 6 20H9C9.55229 20 10 19.5523 10 19V5C10 4.44772 9.55229 4 9 4H6Z" />
</ToggleButton>
Theme="{DynamicResource SplitViewToggleButton}" />
<Border IsVisible="{Binding #splitView.IsPaneOpen}" Theme="{DynamicResource CardBorder}">
<controls:ColorDetailControl
Background="{Binding SelectedColor.Brush}"
IsVisible="{Binding SelectedColor, Converter={x:Static ObjectConverters.IsNotNull}}"
ResourceKey="{Binding SelectedColor.ResourceKey}"
ResourceName="{Binding SelectedColor.ColorDisplayName}" />
<Panel>
<TextBlock
IsVisible="{Binding SelectedColor, Converter={x:Static ObjectConverters.IsNull}}"
Text="Click on Color to Check Details"
TextWrapping="Wrap" />
<controls:ColorDetailControl
Background="{Binding SelectedColor.Brush}"
IsVisible="{Binding SelectedColor, Converter={x:Static ObjectConverters.IsNotNull}}"
ResourceKey="{Binding SelectedColor.ResourceKey}"
ResourceName="{Binding SelectedColor.ColorDisplayName}" />
</Panel>
</Border>
</StackPanel>
</SplitView.Pane>

View File

@ -3,6 +3,7 @@ using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Markup.Xaml;
using Avalonia.Threading;
using Semi.Avalonia.Demo.ViewModels;
namespace Semi.Avalonia.Demo.Pages;
@ -19,7 +20,10 @@ public partial class PaletteDemo : UserControl
{
base.OnApplyTemplate(e);
PaletteDemoViewModel? vm = new PaletteDemoViewModel();
vm.InitializeResources();
await Dispatcher.UIThread.InvokeAsync(() =>
{
vm.InitializeResources();
});
DataContext = vm;
}
}

View File

@ -29,4 +29,29 @@
</Style>
</Style>
</ControlTheme>
<ControlTheme x:Key="SplitViewToggleButton" TargetType="ToggleButton">
<Setter Property="ToggleButton.Template">
<ControlTemplate TargetType="ToggleButton">
<Border
Name="Background"
Padding="8"
Background="{TemplateBinding Background}"
CornerRadius="3">
<PathIcon
Name="Icon"
Width="16"
Height="16"
Data="M5 2H19C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5C2 3.34315 3.34315 2 5 2ZM6 4C5.44772 4 5 4.44772 5 5V19C5 19.5523 5.44772 20 6 20H9C9.55229 20 10 19.5523 10 19V5C10 4.44772 9.55229 4 9 4H6Z"
Foreground="{DynamicResource ButtonDefaultTertiaryForeground}" />
</Border>
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover">
<Setter Property="Background" Value="{DynamicResource ButtonDefaultPointeroverBackground}" />
</Style>
<Style Selector="^:pressed">
<Setter Property="Background" Value="{DynamicResource ButtonDefaultPressedBackground}" />
</Style>
</ControlTheme>
</ResourceDictionary>