Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions src/MahMaterialDragablzMashUp/DialogsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@ public class DialogsViewModel

public ICommand ShowLeftFlyoutCommand { get; }

private ResourceDictionary DialogDictionary = new ResourceDictionary() { Source = new Uri("pack://application:,,,/MaterialDesignThemes.MahApps;component/Themes/MaterialDesignTheme.MahApps.Dialogs.xaml") };
private readonly ResourceDictionary DialogDictionary = new ResourceDictionary() { Source = new Uri("pack://application:,,,/MaterialDesignThemes.MahApps;component/Themes/MaterialDesignTheme.MahApps.Dialogs.xaml") };

public DialogsViewModel()
{
ShowInputDialogCommand = new AnotherCommandImplementation(_ => InputDialog());
ShowProgressDialogCommand = new AnotherCommandImplementation(_ => ProgressDialog());
ShowInputDialogCommand = new AnotherCommandImplementation(async _ => await InputDialog());
ShowProgressDialogCommand = new AnotherCommandImplementation(async _ => await ProgressDialog());
ShowLeftFlyoutCommand = new AnotherCommandImplementation(_ => ShowLeftFlyout());
}

public Flyout? LeftFlyout { get; set; }

private void InputDialog()
private async Task InputDialog()
{
var metroDialogSettings = new MetroDialogSettings
{
CustomResourceDictionary = DialogDictionary,
NegativeButtonText = "CANCEL"
};

DialogCoordinator.Instance.ShowInputAsync(this, "MahApps Dialog", "Using Material Design Themes", metroDialogSettings);
await DialogCoordinator.Instance.ShowInputAsync(this, "MahApps Dialog", "Using Material Design Themes", metroDialogSettings);
}

private async void ProgressDialog()
private async Task ProgressDialog()
{
var metroDialogSettings = new MetroDialogSettings
{
Expand All @@ -49,6 +49,12 @@ private async void ProgressDialog()

private void ShowLeftFlyout()
{
((MainWindow)Application.Current.MainWindow).LeftFlyout.IsOpen = !((MainWindow)Application.Current.MainWindow).LeftFlyout.IsOpen;
// Avoid direct cast to the project's MainWindow type (XAML-generated partials can confuse the analyzer).
// Find the named flyout from the main window and toggle its IsOpen state.
var leftFlyout = Application.Current?.MainWindow?.FindName("LeftFlyout") as Flyout;
if (leftFlyout != null)
{
leftFlyout.IsOpen = !leftFlyout.IsOpen;
}
}
}
2 changes: 1 addition & 1 deletion src/MahMaterialDragablzMashUp/MahViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public int UpDownValue
{
if (value < 0)
{
throw new Exception("Value must be positive");
throw new System.ArgumentOutOfRangeException(nameof(UpDownValue), value, "Value must be non-negative");
}
if (_UpDownValue != value)
{
Expand Down
Loading