-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom dialogs DialogSettings #2775
Conversation
@@ -375,7 +406,8 @@ public static Task HideMetroDialogAsync(this MetroWindow window, BaseMetroDialog | |||
{ | |||
window.RemoveDialog(dialog); | |||
|
|||
return HandleOverlayOnHide(settings,window); | |||
settings = settings ?? dialog.DialogSettings; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this ok, or should it be settings = settings ?? (dialog.DialogSettings ?? window.MetroDialogOptions);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
...with the new overloaded ShowMetroDialogAsync method
It's now possible to do...
the custom dialog for this samples <dialogs:CustomDialog x:Class="ShowMetroDialogAsyncIssue.CustomBaseMetroDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:dialogs="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
Title="CustomBaseMetroDialog">
<StackPanel>
<TextBlock Text="This is a custom dialog based on BaseMetroDialog" />
<Button Click="Close_OnClick">Close</Button>
</StackPanel>
</dialogs:CustomDialog> namespace ShowMetroDialogAsyncIssue
{
using System.Windows;
using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;
public partial class CustomBaseMetroDialog : CustomDialog
{
public CustomBaseMetroDialog()
{
InitializeComponent();
}
public CustomBaseMetroDialog(MetroDialogSettings settings) : base(settings)
{
InitializeComponent();
}
public CustomBaseMetroDialog(MetroWindow parentWindow, MetroDialogSettings settings) : base(parentWindow, settings)
{
InitializeComponent();
}
private void Close_OnClick(object sender, RoutedEventArgs e)
{
(this.OwningWindow ?? (MetroWindow)Application.Current.MainWindow).HideMetroDialogAsync(this);
}
}
} Or
And..It's possible to move the settings stuff to the custom dialog itself. protected override MetroDialogSettings OnGetDialogSettings(MetroDialogSettings settings)
{
return new MyCustomDialogSettings();
} /cc @thoemmi |
/// </summary> | ||
/// <param name="settings"></param> | ||
/// <returns></returns> | ||
protected virtual MetroDialogSettings OnGetDialogSettings(MetroDialogSettings settings) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call this method ConfigureSettings
. E.g. in ASP.NET you have methods like ConfigureServices
, which allow you to intercept and add additional services. Here it allows the user to intercept and change the settings object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx @thoemmi, naming is not my favorite ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There two hard problems in computer science:
- cache invalidation,
- naming things, and
- off-by-1 errors
😉
What changed?
Some changes to fix #2735 MetroWindow.ShowMetroDialogAsync odd behaviour with provided DialogSettings
Closes #2735