Hello,
If you click the maximized button for the second time. The state is Restored, you can judge the state by adding else if(res == OverlappedPresenterState.Restored)
like following code, then send the message as well.
#if WINDOWS
builder.ConfigureLifecycleEvents(events =>
{
events.AddWindows(windowsLifecycleBuilder =>
{
windowsLifecycleBuilder.OnWindowCreated(window =>
{
window.ExtendsContentIntoTitleBar = false;
IntPtr handle = WinRT.Interop.WindowNative.GetWindowHandle(window);
var id = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(handle);
var appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(id);
var p = appWindow.Presenter as OverlappedPresenter;
var titleBar = appWindow.TitleBar;
//detailpage events
appWindow.Changed += (sender, args) => {
if(args.DidSizeChange)
{
OverlappedPresenterState res = p.State;
if (res == OverlappedPresenterState.Maximized)
{
// this will be invoked when maxmized button clicked
WeakReferenceMessenger.Default.Send(new DetailPageStatus("Maximized"));
}
else if (res == OverlappedPresenterState.Minimized)
{
// this will be invoked when Minimized button clicked
WeakReferenceMessenger.Default.Send(new DetailPageStatus("Minimized"));
}
else if(res == OverlappedPresenterState.Restored) {
// this will be invoked when maxmized button clicked second time, the state is restored.
WeakReferenceMessenger.Default.Send(new DetailPageStatus("Restored"));
}
}
};
});
});
});
#endif
In you detailedpage, you can get result of the message and handle the Restored state.
WeakReferenceMessenger.Default.Register<DetailPageStatus>(this, (r, m) =>
{
var res = m.Value;
if (res.Equals("Maximized"))
{
if (res != null)
{
gridDetails.IsVisible = true;
}
else
{
gridDetails.IsVisible = false;
}
}else if (res.Equals("Restored"))
{
// this will be invoked when maxmized button clicked for the second time, the state is restored.
}
});
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.