|
|
|
|
<reactive:ReactiveUserControl xmlns="https://github.com/avaloniaui"
|
|
|
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
|
|
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
|
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
|
|
|
xmlns:vm="using:MyAvaloniaApp.ViewModels.Pages"
|
|
|
|
|
xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
|
|
|
|
|
xmlns:heroicons="clr-namespace:HeroIconsAvalonia.Controls;assembly=HeroIconsAvalonia"
|
|
|
|
|
xmlns:reactive="clr-namespace:Avalonia.ReactiveUI;assembly=Avalonia.ReactiveUI"
|
|
|
|
|
mc:Ignorable="d"
|
|
|
|
|
x:Class="MyAvaloniaApp.Views.Pages.DialogHostPageView"
|
|
|
|
|
x:DataType="vm:DialogHostPageViewModel">
|
|
|
|
|
|
|
|
|
|
<Design.DataContext>
|
|
|
|
|
<vm:DialogHostPageViewModel />
|
|
|
|
|
</Design.DataContext>
|
|
|
|
|
|
|
|
|
|
<dialogHost:DialogHost IsOpen="{Binding IsDialogOpen}">
|
|
|
|
|
<dialogHost:DialogHost.DialogContent>
|
|
|
|
|
<Border Background="{StaticResource BackgroundWhite}"
|
|
|
|
|
CornerRadius="16"
|
|
|
|
|
Padding="24"
|
|
|
|
|
Width="380">
|
|
|
|
|
<StackPanel Spacing="18">
|
|
|
|
|
<Grid ColumnDefinitions="Auto,*" ColumnSpacing="12">
|
|
|
|
|
<Border Grid.Column="0"
|
|
|
|
|
Width="40"
|
|
|
|
|
Height="40"
|
|
|
|
|
CornerRadius="20"
|
|
|
|
|
Background="{Binding DialogAccentBrush}"
|
|
|
|
|
VerticalAlignment="Center">
|
|
|
|
|
<heroicons:HeroIcon Type="{Binding DialogIcon}"
|
|
|
|
|
Width="22"
|
|
|
|
|
Height="22"
|
|
|
|
|
Foreground="White"
|
|
|
|
|
HorizontalAlignment="Center"
|
|
|
|
|
VerticalAlignment="Center"/>
|
|
|
|
|
</Border>
|
|
|
|
|
<StackPanel Grid.Column="1" Spacing="6">
|
|
|
|
|
<TextBlock Text="{Binding DialogTitle}"
|
|
|
|
|
FontSize="18"
|
|
|
|
|
FontWeight="SemiBold"
|
|
|
|
|
Foreground="{StaticResource TextPrimary}"/>
|
|
|
|
|
<TextBlock Text="{Binding DialogMessage}"
|
|
|
|
|
TextWrapping="Wrap"
|
|
|
|
|
FontSize="14"
|
|
|
|
|
Foreground="{StaticResource SecondaryGrayDark}"
|
|
|
|
|
MaxWidth="260"/>
|
|
|
|
|
</StackPanel>
|
|
|
|
|
</Grid>
|
|
|
|
|
|
|
|
|
|
<CheckBox Content="记住我的选择"
|
|
|
|
|
IsChecked="{Binding RememberChoice}"
|
|
|
|
|
Margin="0,4,0,0"
|
|
|
|
|
IsVisible="{Binding IsRememberChoiceVisible}"/>
|
|
|
|
|
|
|
|
|
|
<StackPanel Orientation="Horizontal"
|
|
|
|
|
HorizontalAlignment="Right"
|
|
|
|
|
Spacing="10">
|
|
|
|
|
<Button Content="{Binding SecondaryButtonText}"
|
|
|
|
|
MinWidth="96"
|
|
|
|
|
Command="{Binding CancelDialogCommand}"
|
|
|
|
|
IsVisible="{Binding HasSecondaryButton}"/>
|
|
|
|
|
<Button Content="{Binding PrimaryButtonText}"
|
|
|
|
|
MinWidth="96"
|
|
|
|
|
Command="{Binding ConfirmDialogCommand}"
|
|
|
|
|
Background="{Binding DialogAccentBrush}"
|
|
|
|
|
Foreground="White"
|
|
|
|
|
BorderThickness="0"
|
|
|
|
|
CornerRadius="8"
|
|
|
|
|
IsVisible="{Binding IsPrimaryButtonVisible}"/>
|
|
|
|
|
</StackPanel>
|
|
|
|
|
</StackPanel>
|
|
|
|
|
</Border>
|
|
|
|
|
</dialogHost:DialogHost.DialogContent>
|
|
|
|
|
|
|
|
|
|
<Grid RowDefinitions="Auto,Auto,*" ColumnDefinitions="*" Margin="20" Background="Transparent">
|
|
|
|
|
<StackPanel Spacing="8">
|
|
|
|
|
<TextBlock Text="DialogHost 示例"
|
|
|
|
|
FontSize="20"
|
|
|
|
|
FontWeight="SemiBold"
|
|
|
|
|
Foreground="{StaticResource TextPrimary}"/>
|
|
|
|
|
<TextBlock Text="点击下方按钮体验 DialogHost.Avalonia 提供的模态对话框。"
|
|
|
|
|
FontSize="14"
|
|
|
|
|
Foreground="{StaticResource SecondaryGrayDark}"/>
|
|
|
|
|
</StackPanel>
|
|
|
|
|
|
|
|
|
|
<WrapPanel Grid.Row="1"
|
|
|
|
|
Margin="0,18,0,0"
|
|
|
|
|
Orientation="Horizontal">
|
|
|
|
|
<Button Content="通用提示"
|
|
|
|
|
Padding="18,10"
|
|
|
|
|
Margin="0,0,12,12"
|
|
|
|
|
Command="{Binding ShowDialogCommand}"
|
|
|
|
|
CommandParameter="info"
|
|
|
|
|
Background="#1E3B82F6"
|
|
|
|
|
BorderBrush="Transparent"
|
|
|
|
|
Foreground="{StaticResource TextPrimary}"
|
|
|
|
|
CornerRadius="10"/>
|
|
|
|
|
<Button Content="确认弹窗"
|
|
|
|
|
Padding="18,10"
|
|
|
|
|
Margin="0,0,12,12"
|
|
|
|
|
Command="{Binding ShowDialogCommand}"
|
|
|
|
|
CommandParameter="confirm"
|
|
|
|
|
Background="#1E2563FF"
|
|
|
|
|
BorderBrush="Transparent"
|
|
|
|
|
Foreground="White"
|
|
|
|
|
CornerRadius="10"/>
|
|
|
|
|
<Button Content="成功提示"
|
|
|
|
|
Padding="18,10"
|
|
|
|
|
Margin="0,0,12,12"
|
|
|
|
|
Command="{Binding ShowDialogCommand}"
|
|
|
|
|
CommandParameter="success"
|
|
|
|
|
Background="#FF22C55E"
|
|
|
|
|
BorderBrush="Transparent"
|
|
|
|
|
Foreground="White"
|
|
|
|
|
CornerRadius="10"/>
|
|
|
|
|
<Button Content="失败提示"
|
|
|
|
|
Padding="18,10"
|
|
|
|
|
Margin="0,0,12,12"
|
|
|
|
|
Command="{Binding ShowDialogCommand}"
|
|
|
|
|
CommandParameter="error"
|
|
|
|
|
Background="#FFEF4444"
|
|
|
|
|
BorderBrush="Transparent"
|
|
|
|
|
Foreground="White"
|
|
|
|
|
CornerRadius="10"/>
|
|
|
|
|
<Button Content="警告提示"
|
|
|
|
|
Padding="18,10"
|
|
|
|
|
Margin="0,0,12,12"
|
|
|
|
|
Command="{Binding ShowDialogCommand}"
|
|
|
|
|
CommandParameter="warning"
|
|
|
|
|
Background="#FFF59E0B"
|
|
|
|
|
BorderBrush="Transparent"
|
|
|
|
|
Foreground="{StaticResource TextPrimary}"
|
|
|
|
|
CornerRadius="10"/>
|
|
|
|
|
<Button Content="成功提示(5s)"
|
|
|
|
|
Padding="18,10"
|
|
|
|
|
Margin="0,0,12,12"
|
|
|
|
|
Command="{Binding ShowDialogCommand}"
|
|
|
|
|
CommandParameter="success:5"
|
|
|
|
|
Background="#1422C55E"
|
|
|
|
|
BorderBrush="Transparent"
|
|
|
|
|
Foreground="White"
|
|
|
|
|
CornerRadius="10"/>
|
|
|
|
|
</WrapPanel>
|
|
|
|
|
|
|
|
|
|
<Border Grid.Row="2"
|
|
|
|
|
Margin="0,24,0,0"
|
|
|
|
|
Padding="16"
|
|
|
|
|
Background="{StaticResource BackgroundLight}"
|
|
|
|
|
BorderBrush="{StaticResource BorderLight}"
|
|
|
|
|
BorderThickness="1"
|
|
|
|
|
CornerRadius="8">
|
|
|
|
|
<StackPanel Spacing="6">
|
|
|
|
|
<TextBlock Text="最近操作"
|
|
|
|
|
FontSize="16"
|
|
|
|
|
FontWeight="SemiBold"
|
|
|
|
|
Foreground="{StaticResource TextPrimary}"/>
|
|
|
|
|
<TextBlock Text="{Binding LastActionMessage, FallbackValue=尚未进行任何操作}"/>
|
|
|
|
|
</StackPanel>
|
|
|
|
|
</Border>
|
|
|
|
|
</Grid>
|
|
|
|
|
</dialogHost:DialogHost>
|
|
|
|
|
</reactive:ReactiveUserControl>
|
|
|
|
|
|