优化更新
This commit is contained in:
89
WPFUIAPP/MainWindow.xaml.cs
Normal file
89
WPFUIAPP/MainWindow.xaml.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
|
||||
using Wpf.Ui.Controls;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
|
||||
using MessageBox = Wpf.Ui.Violeta.Controls.MessageBox;
|
||||
|
||||
namespace WPFUIAPP
|
||||
{
|
||||
/// <summary>
|
||||
/// MainWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MainWindow
|
||||
{
|
||||
Wpf.Ui.Controls.ContentDialog dialog;
|
||||
Wpf.Ui.Violeta.Controls.ContentDialog newdialog;
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
dialog = new()
|
||||
{
|
||||
Title = "My sample dialog",
|
||||
Content = "Content of the dialog",
|
||||
CloseButtonText = "Close button",
|
||||
PrimaryButtonText = "Primary button",
|
||||
SecondaryButtonText = "Secondary button",
|
||||
// Setting the dialog container
|
||||
DialogHost = ContentDialogHostService.ContentPresenterForDialogs
|
||||
};
|
||||
newdialog = new()
|
||||
{
|
||||
Title = "My sample dialog",
|
||||
Content = "Content of the dialog",
|
||||
CloseButtonText = "Close button",
|
||||
PrimaryButtonText = "Primary button",
|
||||
SecondaryButtonText = "Secondary button",
|
||||
DefaultButton = Wpf.Ui.Violeta.Controls.ContentDialogButton.Primary,
|
||||
};
|
||||
Splash.CloseOnLoaded(this, minimumMilliseconds: 1800);
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Toast.Information("I am information message");
|
||||
Toast.Error("I am error message");
|
||||
//Toast.Success("I am success message");
|
||||
//Toast.Warning("I am warning message");
|
||||
//Toast.Show(owner: null, "I am any message", new ToastConfig());
|
||||
}
|
||||
|
||||
private void MsgSyncClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_ = MessageBox.Information("This is a information message");
|
||||
_ = MessageBox.Warning("This is a warning message");
|
||||
_ = MessageBox.Error("This is a error message");
|
||||
var result = MessageBox.Question("This is a question and do you want to click OK?");
|
||||
}
|
||||
|
||||
private async void MsgAsyncClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Async methods
|
||||
_ = await MessageBox.InformationAsync("This is a information message");
|
||||
_ = await MessageBox.WarningAsync("This is a warning message");
|
||||
_ = await MessageBox.ErrorAsync("This is a error message");
|
||||
var result = await MessageBox.QuestionAsync("This is a question and do you want to click OK?");
|
||||
}
|
||||
|
||||
private void PendingBoxClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Default style.
|
||||
using IPendingHandler pending = PendingBox.Show();
|
||||
|
||||
// Show with title and cancel button.
|
||||
//using IPendingHandler pending = PendingBox.Show("Doing something", "I'm a title", isShowCancel: true);
|
||||
|
||||
}
|
||||
|
||||
private async void ContentDialogClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await dialog.ShowAsync(CancellationToken.None);
|
||||
}
|
||||
|
||||
private async void NewContentDialogClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_ = await dialog.ShowAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user