Open BaseMetroDialog in another BaseMetroDialog unloaded previous dialog #4320
Unanswered
romigrabarz
asked this question in
Q&A
Replies: 1 comment
-
@romigrabarz This is something what you must handle self like public partial class FirstDialog : BaseMetroDialog
{
private TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
private readonly MetroWindow ParentWindow;
public FirstDialog(MetroWindow parentWindow)
{
InitializeComponent();
ParentWindow = parentWindow;
}
private async void Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
var dialog = new SecondDialog();
await ParentWindow.ShowMetroDialogAsync(dialog);
await dialog.WaitUntilUnloadedAsync();
}
private void ButtonClose_Click(object sender, System.Windows.RoutedEventArgs e)
{
this.tcs.TrySetResult(true);
}
public Task void WaitUntilClosed()
{
return this.tcs.Task;
}
} <mah:BaseMetroDialog x:Class="MahAppMetroDialog.FirstDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
Title="First Dialog">
<StackPanel>
<Button Content="Open Second Dialog" Click="Button_Click"/>
<Button Content="Close this Dialog" Click="ButtonClose_Click"/>
</StackPanel>
</mah:BaseMetroDialog> private async void Button_Click(object sender, RoutedEventArgs e)
{
var dialog = new FirstDialog(this);
await this.ShowMetroDialogAsync(dialog);
Title = "FirstDialog OPEN";
await dialog.WaitUntilClosed();
Title = "FirstDialog CLOSED";
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the bug
I have window as MetroWindow. This window has custom BaseMetroDialog which has button which fire command. This command call another BaseMetroDialog. When I click that button, the first BaseMetroDialog has unloaded - await dialog.WaitUntilUnloadedAsync() ends and program go next line.
Something went wrong when second BaseMetroDialog goes to ShowMetroDialogAsync.
Steps to reproduce
MainWindow
FirstDialog
SecondDialog
Expected behavior
Open another Dialog in Dialog shouldn't unloaded previous Dialog. When I close second dialog, I want go back to first dialog before its unloaded.
Actual behavior
Open another Dialog in Dialog unloaded previous dialog.
Environment
Screenshots
Beta Was this translation helpful? Give feedback.
All reactions