// 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 _navigationCards = new ObservableCollection( 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 ContentDialogService contentDialogService; [ObservableProperty] private string _dialogResultText = string.Empty; [RelayCommand] private async Task OnShowDialog(object content) { ContentDialogResult result = await contentDialogService.ShowSimpleDialogAsync( new SimpleContentDialogOptions() { 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 }