feat: add new dialog samples.
This commit is contained in:
83
demo/Ursa.Demo/Dialogs/CustomDemoDialog.axaml
Normal file
83
demo/Ursa.Demo/Dialogs/CustomDemoDialog.axaml
Normal file
@@ -0,0 +1,83 @@
|
||||
<UserControl
|
||||
x:Class="Ursa.Demo.Dialogs.CustomDemoDialog"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:dialogs="clr-namespace:Ursa.Demo.Dialogs"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:u="https://irihi.tech/ursa"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
x:DataType="dialogs:CustomDemoDialogViewModel"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Background>
|
||||
<LinearGradientBrush StartPoint="5%, 5%" EndPoint="80%, 80%">
|
||||
<GradientStop Offset="0.0" Color="{DynamicResource SemiBlue0Color}" />
|
||||
<GradientStop Offset="0.4" Color="{DynamicResource SemiBlue2Color}" />
|
||||
<GradientStop Offset="0.9" Color="{DynamicResource SemiBlue1Color}" />
|
||||
</LinearGradientBrush>
|
||||
</UserControl.Background>
|
||||
<Grid Margin="24" RowDefinitions="Auto, *, Auto" MinWidth="400">
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Margin="8"
|
||||
FontSize="16"
|
||||
FontWeight="600"
|
||||
Text="Add New" />
|
||||
<u:Form
|
||||
Grid.Row="1"
|
||||
Margin="24"
|
||||
HorizontalAlignment="Stretch"
|
||||
LabelPosition="Top">
|
||||
<u:Form.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<Grid ColumnDefinitions="Auto, *" RowDefinitions="Auto, *" />
|
||||
</ItemsPanelTemplate>
|
||||
</u:Form.ItemsPanel>
|
||||
<u:FormItem Label="Country/Region">
|
||||
<ComboBox
|
||||
Width="120"
|
||||
ItemsSource="{Binding Cities}"
|
||||
SelectedItem="{Binding City}" />
|
||||
</u:FormItem>
|
||||
<u:FormItem
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Margin="32,8,0,8"
|
||||
Label="Owner">
|
||||
<TextBox u:FormItem.Label="Owner" Text="{Binding Owner}" />
|
||||
</u:FormItem>
|
||||
<u:FormItem
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Label="Target">
|
||||
<ComboBox
|
||||
Width="120"
|
||||
ItemsSource="{Binding Cities}"
|
||||
SelectedItem="{Binding Target}" />
|
||||
</u:FormItem>
|
||||
<u:FormItem
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="32,8,0,8"
|
||||
Label="Department">
|
||||
<TextBox Text="{Binding Department}" />
|
||||
</u:FormItem>
|
||||
</u:Form>
|
||||
<StackPanel
|
||||
Grid.Row="2"
|
||||
HorizontalAlignment="Right"
|
||||
Orientation="Horizontal"
|
||||
Spacing="8">
|
||||
<Button Command="{Binding DialogCommand}" Content="Dialog" />
|
||||
<Button Command="{Binding OKCommand}" Content="OK" />
|
||||
<Button Command="{Binding CancelCommand}" Content="Cancel" />
|
||||
<ComboBox>
|
||||
<ComboBoxItem>A</ComboBoxItem>
|
||||
<ComboBoxItem>B</ComboBoxItem>
|
||||
<ComboBoxItem>C</ComboBoxItem>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
13
demo/Ursa.Demo/Dialogs/CustomDemoDialog.axaml.cs
Normal file
13
demo/Ursa.Demo/Dialogs/CustomDemoDialog.axaml.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace Ursa.Demo.Dialogs;
|
||||
|
||||
public partial class CustomDemoDialog : UserControl
|
||||
{
|
||||
public CustomDemoDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
59
demo/Ursa.Demo/Dialogs/CustomDemoDialogViewModel.cs
Normal file
59
demo/Ursa.Demo/Dialogs/CustomDemoDialogViewModel.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Irihi.Avalonia.Shared.Contracts;
|
||||
using Ursa.Controls;
|
||||
|
||||
namespace Ursa.Demo.Dialogs;
|
||||
|
||||
public partial class CustomDemoDialogViewModel : ObservableObject, IDialogContext
|
||||
{
|
||||
[ObservableProperty] private string? _city;
|
||||
[ObservableProperty] private string? _department;
|
||||
[ObservableProperty] private string? _owner;
|
||||
[ObservableProperty] private string? _target;
|
||||
|
||||
public CustomDemoDialogViewModel()
|
||||
{
|
||||
Cities =
|
||||
[
|
||||
"Shanghai", "Beijing", "Hulunbuir", "Shenzhen", "Hangzhou", "Nanjing", "Chengdu", "Wuhan", "Chongqing",
|
||||
"Suzhou", "Tianjin", "Xi'an", "Qingdao", "Dalian"
|
||||
];
|
||||
OKCommand = new RelayCommand(OK);
|
||||
CancelCommand = new RelayCommand(Cancel);
|
||||
DialogCommand = new AsyncRelayCommand(ShowDialog);
|
||||
}
|
||||
|
||||
public ObservableCollection<string> Cities { get; set; }
|
||||
|
||||
public void Close()
|
||||
{
|
||||
RequestClose?.Invoke(this, null);
|
||||
}
|
||||
|
||||
public event EventHandler<object?>? RequestClose;
|
||||
|
||||
public ICommand OKCommand { get; set; }
|
||||
public ICommand CancelCommand { get; set; }
|
||||
|
||||
public ICommand DialogCommand { get; set; }
|
||||
|
||||
private void OK()
|
||||
{
|
||||
RequestClose?.Invoke(this, true);
|
||||
}
|
||||
|
||||
private void Cancel()
|
||||
{
|
||||
RequestClose?.Invoke(this, false);
|
||||
}
|
||||
|
||||
private async Task ShowDialog()
|
||||
{
|
||||
await OverlayDialog.ShowCustomModal<CustomDemoDialog, CustomDemoDialogViewModel, bool>(new CustomDemoDialogViewModel());
|
||||
}
|
||||
}
|
||||
50
demo/Ursa.Demo/Dialogs/DefaultDemoDialog.axaml
Normal file
50
demo/Ursa.Demo/Dialogs/DefaultDemoDialog.axaml
Normal file
@@ -0,0 +1,50 @@
|
||||
<UserControl
|
||||
x:Class="Ursa.Demo.Dialogs.DefaultDemoDialog"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:dialogs="clr-namespace:Ursa.Demo.Dialogs"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:u="https://irihi.tech/ursa"
|
||||
MinWidth="400"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
x:DataType="dialogs:DefaultDemoDialogViewModel"
|
||||
mc:Ignorable="d">
|
||||
<u:Form HorizontalAlignment="Stretch" LabelPosition="Top">
|
||||
<u:Form.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<Grid ColumnDefinitions="Auto, *" RowDefinitions="Auto, *" />
|
||||
</ItemsPanelTemplate>
|
||||
</u:Form.ItemsPanel>
|
||||
<u:FormItem Label="Country/Region">
|
||||
<ComboBox
|
||||
Width="120"
|
||||
ItemsSource="{Binding Cities}"
|
||||
SelectedItem="{Binding City}" />
|
||||
</u:FormItem>
|
||||
<u:FormItem
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Margin="32,8,0,8"
|
||||
Label="Owner">
|
||||
<TextBox u:FormItem.Label="Owner" Text="{Binding Owner}" />
|
||||
</u:FormItem>
|
||||
<u:FormItem
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Label="Target">
|
||||
<ComboBox
|
||||
Width="120"
|
||||
ItemsSource="{Binding Cities}"
|
||||
SelectedItem="{Binding Target}" />
|
||||
</u:FormItem>
|
||||
<u:FormItem
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="32,8,0,8"
|
||||
Label="Department">
|
||||
<TextBox Text="{Binding Department}" />
|
||||
</u:FormItem>
|
||||
</u:Form>
|
||||
</UserControl>
|
||||
13
demo/Ursa.Demo/Dialogs/DefaultDemoDialog.axaml.cs
Normal file
13
demo/Ursa.Demo/Dialogs/DefaultDemoDialog.axaml.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace Ursa.Demo.Dialogs;
|
||||
|
||||
public partial class DefaultDemoDialog : UserControl
|
||||
{
|
||||
public DefaultDemoDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
31
demo/Ursa.Demo/Dialogs/DefaultDemoDialogViewModel.cs
Normal file
31
demo/Ursa.Demo/Dialogs/DefaultDemoDialogViewModel.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Irihi.Avalonia.Shared.Contracts;
|
||||
|
||||
namespace Ursa.Demo.Dialogs;
|
||||
|
||||
public partial class DefaultDemoDialogViewModel: ObservableObject, IDialogContext
|
||||
{
|
||||
public ObservableCollection<string> Cities { get; set; }
|
||||
[ObservableProperty] private string? _owner;
|
||||
[ObservableProperty] private string? _department;
|
||||
[ObservableProperty] private string? _target;
|
||||
[ObservableProperty] private string? _city;
|
||||
|
||||
public DefaultDemoDialogViewModel()
|
||||
{
|
||||
Cities =
|
||||
[
|
||||
"Shanghai", "Beijing", "Hulunbuir", "Shenzhen", "Hangzhou", "Nanjing", "Chengdu", "Wuhan", "Chongqing",
|
||||
"Suzhou", "Tianjin", "Xi'an", "Qingdao", "Dalian"
|
||||
];
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
RequestClose?.Invoke(this, null);
|
||||
}
|
||||
|
||||
public event EventHandler<object?>? RequestClose;
|
||||
}
|
||||
Reference in New Issue
Block a user