feat: 1. Update dependency.

2. Provide sample for Dialog StyleClass option.
This commit is contained in:
rabbitism
2024-11-03 22:26:14 +08:00
parent ee707cd977
commit 9d394753d7
10 changed files with 175 additions and 166 deletions

View File

@@ -3,9 +3,18 @@
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:semi="https://irihi.tech/semi"
xmlns:u-semi="https://irihi.tech/ursa/themes/semi">
xmlns:u-semi="https://irihi.tech/ursa/themes/semi"
xmlns:u="https://irihi.tech/ursa"
xmlns:helpers="clr-namespace:Irihi.Avalonia.Shared.Helpers;assembly=Irihi.Avalonia.Shared">
<Application.Styles>
<semi:SemiTheme Locale="zh-CN" />
<u-semi:SemiTheme Locale="zh-CN" />
<!--This style is created to demonstrate Dialog StyleClass feature. This style is applied to Dialog Window-->
<Style Selector="u|DefaultDialogWindow.Custom">
<Style Selector="^ /template/ Button#PART_OKButton">
<Setter Property="Content" Value="CUSTOM"/>
<Setter Property="helpers:ClassHelper.Classes" Value="Warning"></Setter>
</Style>
</Style>
</Application.Styles>
</Application>

View File

@@ -51,6 +51,21 @@
IsThreeState="True" />
<CheckBox u:FormItem.Label="CanDragMove" IsChecked="{Binding CanDragMove}" />
<CheckBox u:FormItem.Label="CanResize" IsChecked="{Binding CanResize}" />
<u:FormItem>
<u:FormItem.Label>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Style Class" />
<PathIcon
Width="12"
Height="12"
VerticalAlignment="Center"
TextElement.FontWeight="Normal"
Data="{DynamicResource DialogQuestionIconGlyph}"
ToolTip.Tip="Pass a Style Class to the created Dialog. In this example, if you set StyleClass as 'Custom', You will get Special Style for OK Button. These styles usually are defined in the root of your App/Window" />
</StackPanel>
</u:FormItem.Label>
<TextBox HorizontalAlignment="Stretch" Text="{Binding StyleClass}" />
</u:FormItem>
<Button
HorizontalAlignment="Left"
u:FormItem.NoLabel="True"
@@ -128,6 +143,21 @@
IsChecked="{Binding IsLocal}"
OffContent="Global"
OnContent="Local" />
<u:FormItem>
<u:FormItem.Label>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Style Class" />
<PathIcon
Width="12"
Height="12"
VerticalAlignment="Center"
TextElement.FontWeight="Normal"
Data="{DynamicResource DialogQuestionIconGlyph}"
ToolTip.Tip="Pass a Style Class to the created Dialog. In this example, if you set StyleClass as 'Custom', You will get Special Style for OK Button. These styles usually are defined in the root of your App/Window" />
</StackPanel>
</u:FormItem.Label>
<TextBox HorizontalAlignment="Stretch" Text="{Binding StyleClass}" />
</u:FormItem>
<Button
HorizontalAlignment="Left"
u:FormItem.NoLabel="True"

View File

@@ -33,6 +33,7 @@ public partial class DefaultWindowDialogDemoViewModel: ObservableObject
[ObservableProperty] private bool? _isCloseButtonVisible;
[ObservableProperty] private bool _canDragMove;
[ObservableProperty] private bool _canResize;
[ObservableProperty] private string? _styleClass;
public ICommand ShowDialogCommand { get; }
@@ -57,6 +58,7 @@ public partial class DefaultWindowDialogDemoViewModel: ObservableObject
StartupLocation = Location,
CanDragMove = CanDragMove,
CanResize = CanResize,
StyleClass = StyleClass,
};
if (X.HasValue && Y.HasValue)
{
@@ -133,6 +135,7 @@ public partial class DefaultOverlayDialogDemoViewModel : ObservableObject
[ObservableProperty] private bool _isModal;
[ObservableProperty] private bool _isLocal;
[ObservableProperty] private bool _canResize;
[ObservableProperty] private string? _styleClass;
public ICommand ShowDialogCommand { get; }
@@ -163,7 +166,7 @@ public partial class DefaultOverlayDialogDemoViewModel : ObservableObject
CanDragMove = CanDragMove,
IsCloseButtonVisible = IsCloseButtonVisible,
CanResize = CanResize,
StyleClass = "Alert",
StyleClass = StyleClass,
};
string? dialogHostId = IsLocal ? DialogDemoViewModel.LocalHost : null;
if (IsModal)

View File

@@ -3,21 +3,31 @@
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:helpers="clr-namespace:Irihi.Avalonia.Shared.Helpers;assembly=Irihi.Avalonia.Shared"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="clr-namespace:Ursa.Demo.Views"
xmlns:u="https://irihi.tech/ursa"
xmlns:viewModels="clr-namespace:Ursa.Demo.ViewModels"
xmlns:views="clr-namespace:Ursa.Demo.Views"
Title="Ursa.Demo"
d:DesignHeight="450"
d:DesignWidth="800"
x:CompileBindings="True"
IsFullScreenButtonVisible="{OnPlatform True, macOS=False}"
IsManagedResizerVisible="{OnPlatform False, Linux=True}"
x:DataType="viewModels:MainWindowViewModel"
Icon="/Assets/Ursa.ico"
IsFullScreenButtonVisible="{OnPlatform True, macOS=False}"
IsManagedResizerVisible="{OnPlatform False, Linux=True}"
mc:Ignorable="d">
<u:UrsaWindow.RightContent>
<views:TitleBarRightContent/>
<views:TitleBarRightContent />
</u:UrsaWindow.RightContent>
<u:UrsaWindow.Styles>
<!--This style is created to demonstrate Dialog StyleClass feature. This style is applied to dialogs in MainWindow OverlayDialogHost -->
<Style Selector="u|DefaultDialogControl.Custom">
<Style Selector="^ /template/ Button#PART_OKButton">
<Setter Property="Content" Value="CUSTOM" />
<Setter Property="helpers:ClassHelper.Classes" Value="Warning" />
</Style>
</Style>
</u:UrsaWindow.Styles>
<views:MainView />
</u:UrsaWindow>