Files
ShrlAlgoToolkit/WPFluent.Gallery/ViewModels/Pages/DialogsAndFlyoutsViewModel.cs

97 lines
3.2 KiB
C#
Raw Normal View History

2025-04-24 20:56:44 +08:00
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
using System.Diagnostics.CodeAnalysis;
using WPFluent.Extensions;
using WPFluent.Gallery.Controls;
using WPFluent.Gallery.ControlsLookup;
using WPFluent.Gallery.Models;
using WPFluent.Gallery.Views.Pages;
namespace WPFluent.Gallery.ViewModels.Pages;
public partial class DialogsAndFlyoutsViewModel : ViewModel
{
[ObservableProperty]
private ICollection<NavigationCard> _navigationCards = new ObservableCollection<NavigationCard>(
ControlPages
.FromNamespace(typeof(DialogsAndFlyoutsPage).Namespace!)
.Select(x => new NavigationCard()
{
Name = x.Name,
Icon = x.Icon,
Description = x.Description,
PageType = x.PageType,
})
);
[SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "relay command")]
[RelayCommand]
private void OnOpenStandardMessageBox(object sender)
{
_ = System.Windows.MessageBox.Show("Something about to happen", "I can feel it");
}
[SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "relay command")]
[RelayCommand]
private async Task OnOpenCustomMessageBox(object sender)
{
var uiMessageBox = new WPFluent.Controls.MessageWindow
{
Title = "WPF UI Message Box",
Content =
"Never gonna give you up, never gonna let you down Never gonna run around and desert you Never gonna make you cry, never gonna say goodbye",
};
_ = await uiMessageBox.ShowDialogAsync();
}
[ObservableProperty]
private bool _isFlyoutOpen = false;
[RelayCommand]
private void OnButtonClick(object sender)
{
if (!IsFlyoutOpen)
{
IsFlyoutOpen = true;
}
}
#region ContentDialog
2025-05-05 17:04:06 +08:00
ContentDialogService contentDialogService;
2025-04-24 20:56:44 +08:00
[ObservableProperty]
private string _dialogResultText = string.Empty;
[RelayCommand]
private async Task OnShowDialog(object content)
{
ContentDialogResult result = await contentDialogService.ShowSimpleDialogAsync(
2025-05-05 17:04:06 +08:00
new SimpleContentDialogOptions()
2025-04-24 20:56:44 +08:00
{
Title = "Save your work?",
Content = content,
PrimaryButtonText = "Save",
SecondaryButtonText = "Don't Save",
CloseButtonText = "Cancel",
}
);
DialogResultText = result switch
{
ContentDialogResult.Primary => "User saved their work",
ContentDialogResult.Secondary => "User did not save their work",
_ => "User cancelled the dialog",
};
}
[RelayCommand]
private async Task OnShowSignInContentDialog()
{
var termsOfUseContentDialog = new TermsOfUseContentDialog(contentDialogService.GetDialogHost());
_ = await termsOfUseContentDialog.ShowAsync();
}
#endregion
}