diff --git a/samples/NotificationFlyoutSample/NotificationFlyoutSample.csproj b/samples/NotificationFlyoutSample/NotificationFlyoutSample.csproj
index 50b549f..4ce7fa6 100644
--- a/samples/NotificationFlyoutSample/NotificationFlyoutSample.csproj
+++ b/samples/NotificationFlyoutSample/NotificationFlyoutSample.csproj
@@ -123,6 +123,9 @@
Shell.xaml
+
+ WindowContent.xaml
+
@@ -163,6 +166,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
diff --git a/samples/NotificationFlyoutSample/Shell.xaml b/samples/NotificationFlyoutSample/Shell.xaml
index 5b583bc..3f44d5d 100644
--- a/samples/NotificationFlyoutSample/Shell.xaml
+++ b/samples/NotificationFlyoutSample/Shell.xaml
@@ -44,7 +44,7 @@
IsIndeterminate="True"
ShowError="False"
ShowPaused="False" />
-
+
diff --git a/samples/NotificationFlyoutSample/Shell.xaml.cs b/samples/NotificationFlyoutSample/Shell.xaml.cs
index f78b594..f1f9ba2 100644
--- a/samples/NotificationFlyoutSample/Shell.xaml.cs
+++ b/samples/NotificationFlyoutSample/Shell.xaml.cs
@@ -28,5 +28,11 @@
var app = GetApplication();
app.Exit();
}
+
+ private void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
+ {
+ var app = GetApplication();
+ app.OpenAsWindow();
+ }
}
}
diff --git a/samples/NotificationFlyoutSample/WindowContent.xaml b/samples/NotificationFlyoutSample/WindowContent.xaml
new file mode 100644
index 0000000..2088c37
--- /dev/null
+++ b/samples/NotificationFlyoutSample/WindowContent.xaml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/NotificationFlyoutSample/WindowContent.xaml.cs b/samples/NotificationFlyoutSample/WindowContent.xaml.cs
new file mode 100644
index 0000000..2522012
--- /dev/null
+++ b/samples/NotificationFlyoutSample/WindowContent.xaml.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+
+// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
+
+namespace NotificationFlyoutSample
+{
+ public sealed partial class WindowContent : UserControl
+ {
+ public WindowContent()
+ {
+ this.InitializeComponent();
+ }
+ }
+}
diff --git a/src/NotificationFlyout.Uwp.UI/INotificationFlyoutApplication.cs b/src/NotificationFlyout.Uwp.UI/INotificationFlyoutApplication.cs
index f09bd81..5e4481b 100644
--- a/src/NotificationFlyout.Uwp.UI/INotificationFlyoutApplication.cs
+++ b/src/NotificationFlyout.Uwp.UI/INotificationFlyoutApplication.cs
@@ -1,7 +1,11 @@
-namespace NotificationFlyout.Uwp.UI
+using Windows.UI.Xaml;
+
+namespace NotificationFlyout.Uwp.UI
{
public interface INotificationFlyoutApplication
{
void Exit();
+
+ void OpenAsWindow() where TUIElement : UIElement;
}
}
diff --git a/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyoutApplication.cs b/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyoutApplication.cs
index 18ddd84..c8afc3d 100644
--- a/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyoutApplication.cs
+++ b/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyoutApplication.cs
@@ -48,6 +48,12 @@ namespace NotificationFlyout.Wpf.UI.Controls
_notificationFlyoutXamlHost.HideFlyout();
}
+ public void OpenAsWindow() where TUIElement : Windows.UI.Xaml.UIElement
+ {
+ var window = new XamlHost();
+ window.Show();
+ }
+
public void ShowFlyout()
{
_notificationFlyoutXamlHost.ShowFlyout();
diff --git a/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/XamlHostWindow.cs b/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/XamlHostWindow.cs
deleted file mode 100644
index 3e7a24d..0000000
--- a/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/XamlHostWindow.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-using Microsoft.Toolkit.Wpf.UI.XamlHost;
-using NotificationFlyout.Wpf.UI.Extensions;
-using System;
-using System.Windows;
-using System.Windows.Media;
-
-namespace NotificationFlyout.Wpf.UI.Controls
-{
- internal class XamlHostWindow : Window where TXamlContent : Windows.UI.Xaml.UIElement
- {
- internal const double WindowSize = 5;
- protected new bool IsLoaded;
- private WindowsXamlHost _xamlHost;
- public XamlHostWindow()
- {
- PrepareDefaultWindow();
- PrepareWindowsXamlHost();
-
- Loaded += OnLoaded;
- ContentRendered += OnContentRendered;
- }
-
- internal TXamlContent GetHostContent()
- {
- if (_xamlHost == null) return null;
- return _xamlHost.GetUwpInternalObject() as TXamlContent;
- }
-
- protected virtual void OnContentLoaded()
- {
- }
-
- private void OnContentRendered(object sender, EventArgs args)
- {
- IsLoaded = true;
- OnContentLoaded();
- }
-
- private void OnLoaded(object sender, RoutedEventArgs args)
- {
- this.Hidden();
- }
-
- private void PrepareDefaultWindow()
- {
- ShowInTaskbar = false;
- ShowActivated = false;
- WindowStyle = WindowStyle.None;
- ResizeMode = ResizeMode.NoResize;
- AllowsTransparency = true;
- Background = new SolidColorBrush(Colors.Transparent);
- Height = WindowSize;
- Width = WindowSize;
- }
-
- private void PrepareWindowsXamlHost()
- {
- _xamlHost = new WindowsXamlHost
- {
- InitialTypeName = typeof(TXamlContent).FullName,
- Height = 0,
- Width = 0,
- HorizontalAlignment = HorizontalAlignment.Stretch,
- VerticalAlignment = VerticalAlignment.Stretch
- };
-
- Content = _xamlHost;
- }
- }
-}
\ No newline at end of file
diff --git a/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyoutContextMenuXamlHost.cs b/src/NotificationFlyout.Wpf.UI.Controls/XamlHost/NotificationFlyoutContextMenuXamlHost.cs
similarity index 96%
rename from src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyoutContextMenuXamlHost.cs
rename to src/NotificationFlyout.Wpf.UI.Controls/XamlHost/NotificationFlyoutContextMenuXamlHost.cs
index 6c7b169..52a36b0 100644
--- a/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyoutContextMenuXamlHost.cs
+++ b/src/NotificationFlyout.Wpf.UI.Controls/XamlHost/NotificationFlyoutContextMenuXamlHost.cs
@@ -7,7 +7,7 @@ using Windows.UI.Xaml.Controls;
namespace NotificationFlyout.Wpf.UI.Controls
{
- internal class ContextMenuXamlHost : XamlHostWindow
+ internal class ContextMenuXamlHost : TransparentXamlHost
{
private Uwp.UI.Controls.NotificationFlyout _flyout;
diff --git a/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyoutXamlHost.cs b/src/NotificationFlyout.Wpf.UI.Controls/XamlHost/NotificationFlyoutXamlHost.cs
similarity index 98%
rename from src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyoutXamlHost.cs
rename to src/NotificationFlyout.Wpf.UI.Controls/XamlHost/NotificationFlyoutXamlHost.cs
index b1aeecf..378926f 100644
--- a/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyoutXamlHost.cs
+++ b/src/NotificationFlyout.Wpf.UI.Controls/XamlHost/NotificationFlyoutXamlHost.cs
@@ -1,15 +1,15 @@
using NotificationFlyout.Uwp.UI.Controls;
-using NotificationFlyout.Wpf.UI.Extensions;
using NotificationFlyout.Uwp.UI.Extensions;
+using NotificationFlyout.Wpf.UI.Extensions;
using NotificationFlyout.Wpf.UI.Helpers;
using System;
using System.Windows;
-using Windows.UI.Xaml.Controls.Primitives;
using System.Windows.Input;
+using Windows.UI.Xaml.Controls.Primitives;
namespace NotificationFlyout.Wpf.UI.Controls
{
- internal class NotificationFlyoutXamlHost : XamlHostWindow
+ internal class NotificationFlyoutXamlHost : TransparentXamlHost
{
private const string ShellTrayHandleName = "Shell_TrayWnd";
@@ -176,7 +176,6 @@ namespace NotificationFlyout.Wpf.UI.Controls
_notificationIconHelper.SetIcon(icon.Handle);
}
-
private void UpdateRequestedTheme()
{
if (_flyout == null) return;
@@ -216,24 +215,28 @@ namespace NotificationFlyout.Wpf.UI.Controls
height = windowHeight;
width = windowWidth;
break;
+
case TaskbarPosition.Top:
top = taskbarRect.Bottom;
left = FlowDirection == FlowDirection.RightToLeft ? taskbarRect.Left : taskbarRect.Right - windowWidth;
height = windowHeight;
width = windowWidth;
break;
+
case TaskbarPosition.Right:
top = taskbarRect.Bottom - windowHeight;
left = taskbarRect.Left - windowWidth;
height = windowHeight;
width = windowWidth;
break;
+
case TaskbarPosition.Bottom:
top = taskbarRect.Top - windowHeight;
left = FlowDirection == FlowDirection.RightToLeft ? taskbarRect.Left : taskbarRect.Right - windowWidth;
height = windowHeight;
width = windowWidth;
break;
+
default:
throw new ArgumentOutOfRangeException();
}
diff --git a/src/NotificationFlyout.Wpf.UI.Controls/XamlHost/TransparentXamlHost.cs b/src/NotificationFlyout.Wpf.UI.Controls/XamlHost/TransparentXamlHost.cs
new file mode 100644
index 0000000..bdb64fd
--- /dev/null
+++ b/src/NotificationFlyout.Wpf.UI.Controls/XamlHost/TransparentXamlHost.cs
@@ -0,0 +1,43 @@
+using Microsoft.Toolkit.Wpf.UI.XamlHost;
+using NotificationFlyout.Wpf.UI.Extensions;
+using System.Windows;
+using System.Windows.Media;
+
+namespace NotificationFlyout.Wpf.UI.Controls
+{
+ internal class TransparentXamlHost : XamlHost where TXamlContent : Windows.UI.Xaml.UIElement
+ {
+ internal const double WindowSize = 5;
+
+ public TransparentXamlHost()
+ {
+ Loaded += OnLoaded;
+ PrepareDefaultWindow();
+ }
+
+ protected override WindowsXamlHost OnPreparingXamlHost(WindowsXamlHost xamlHost)
+ {
+ xamlHost.Height = 0;
+ xamlHost.Width = 0;
+
+ return base.OnPreparingXamlHost(xamlHost);
+ }
+
+ private void OnLoaded(object sender, RoutedEventArgs args)
+ {
+ this.Hidden();
+ }
+
+ private void PrepareDefaultWindow()
+ {
+ ShowInTaskbar = false;
+ ShowActivated = false;
+ WindowStyle = WindowStyle.None;
+ ResizeMode = ResizeMode.NoResize;
+ AllowsTransparency = true;
+ Background = new SolidColorBrush(Colors.Transparent);
+ Height = WindowSize;
+ Width = WindowSize;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/NotificationFlyout.Wpf.UI.Controls/XamlHost/XamlHost.cs b/src/NotificationFlyout.Wpf.UI.Controls/XamlHost/XamlHost.cs
new file mode 100644
index 0000000..6f84fea
--- /dev/null
+++ b/src/NotificationFlyout.Wpf.UI.Controls/XamlHost/XamlHost.cs
@@ -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 : 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;
+ }
+ }
+}
\ No newline at end of file