Added API for opening a window from flyout w/ sample
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
using Microsoft.Toolkit.Wpf.UI.XamlHost;
|
||||
using NotificationFlyout.Wpf.UI.Extensions;
|
||||
using System;
|
||||
using System.Windows;
|
||||
|
||||
namespace NotificationFlyout.Wpf.UI.Controls
|
||||
{
|
||||
internal class XamlHost<TXamlContent> : Window where TXamlContent : Windows.UI.Xaml.UIElement
|
||||
{
|
||||
protected new bool IsLoaded;
|
||||
private WindowsXamlHost _xamlHost;
|
||||
|
||||
public XamlHost()
|
||||
{
|
||||
PrepareWindowsXamlHost();
|
||||
ContentRendered += OnContentRendered;
|
||||
}
|
||||
|
||||
protected TXamlContent GetHostContent()
|
||||
{
|
||||
if (_xamlHost == null) return null;
|
||||
return _xamlHost.GetUwpInternalObject() as TXamlContent;
|
||||
}
|
||||
|
||||
protected virtual void OnContentLoaded()
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual WindowsXamlHost OnPreparingXamlHost(WindowsXamlHost xamlHost)
|
||||
{
|
||||
xamlHost.InitialTypeName = typeof(TXamlContent).FullName;
|
||||
xamlHost.HorizontalAlignment = HorizontalAlignment.Stretch;
|
||||
xamlHost.VerticalAlignment = VerticalAlignment.Stretch;
|
||||
|
||||
return xamlHost;
|
||||
}
|
||||
|
||||
private void OnContentRendered(object sender, EventArgs args)
|
||||
{
|
||||
IsLoaded = true;
|
||||
OnContentLoaded();
|
||||
}
|
||||
|
||||
private void PrepareWindowsXamlHost()
|
||||
{
|
||||
_xamlHost = new WindowsXamlHost();
|
||||
OnPreparingXamlHost(_xamlHost);
|
||||
|
||||
Content = _xamlHost;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user