Project changes meaning the UWP stuff cannot relay on .Common stuff, this all has all happen in the host and then referred up to the UWP control, or else the UWP project would of had to carry a boat load of unsupported packages!!
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
</controls:NotificationFlyout.FlyoutPresenterStyle>
|
||||
<controls:NotificationFlyout.ContextMenu>
|
||||
<controls:NotificationFlyoutContextMenu>
|
||||
<MenuFlyoutItem Text="Close" />
|
||||
<MenuFlyoutItem Click="MenuFlyoutItem_Click" Text="Close" />
|
||||
</controls:NotificationFlyoutContextMenu>
|
||||
</controls:NotificationFlyout.ContextMenu>
|
||||
<Grid Width="400" Margin="24">
|
||||
|
||||
+36
-20
@@ -20,11 +20,12 @@ namespace TheXamlGuy.NotificationFlyout.Uwp.UI.Controls
|
||||
new PropertyMetadata(null));
|
||||
|
||||
private Flyout _flyout;
|
||||
private bool _isColorPrevalence;
|
||||
private bool _isLoaded;
|
||||
private NotificationFlyout _notificationFlyout;
|
||||
private NotificationFlyoutPresenter _notificationFlyoutPresenter;
|
||||
private string _placement;
|
||||
private Grid _root;
|
||||
|
||||
public NotificationFlyoutHost() => DefaultStyleKey = typeof(NotificationFlyoutHost);
|
||||
|
||||
public UIElement Content
|
||||
@@ -48,24 +49,8 @@ namespace TheXamlGuy.NotificationFlyout.Uwp.UI.Controls
|
||||
|
||||
public void SetFlyoutPlacement(string placement)
|
||||
{
|
||||
if (!_isLoaded)
|
||||
{
|
||||
_placement = placement;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(placement)) return;
|
||||
VisualStateManager.GoToState(this, placement, true);
|
||||
}
|
||||
|
||||
public void ShowFlyout(FlyoutPlacementMode placementMode)
|
||||
{
|
||||
if (_root == null) return;
|
||||
var flyout = FlyoutBase.GetAttachedFlyout(_root);
|
||||
flyout.ShowAt(_root, new FlyoutShowOptions
|
||||
{
|
||||
Placement = placementMode,
|
||||
ShowMode = FlyoutShowMode.Transient,
|
||||
});
|
||||
_placement = placement;
|
||||
UpdateFlyoutVisualState();
|
||||
}
|
||||
|
||||
public void SetOwningFlyout(NotificationFlyout flyout)
|
||||
@@ -98,8 +83,31 @@ namespace TheXamlGuy.NotificationFlyout.Uwp.UI.Controls
|
||||
});
|
||||
}
|
||||
|
||||
public void ShowFlyout(FlyoutPlacementMode placementMode)
|
||||
{
|
||||
if (_root == null) return;
|
||||
var flyout = FlyoutBase.GetAttachedFlyout(_root);
|
||||
flyout.ShowAt(_root, new FlyoutShowOptions
|
||||
{
|
||||
Placement = placementMode,
|
||||
ShowMode = FlyoutShowMode.Transient,
|
||||
});
|
||||
}
|
||||
|
||||
public void UpdateTheme(bool isColorPrevalence)
|
||||
{
|
||||
_isColorPrevalence = isColorPrevalence;
|
||||
if (_notificationFlyoutPresenter == null) return;
|
||||
_notificationFlyoutPresenter.UpdateThemeVisualState(isColorPrevalence);
|
||||
}
|
||||
|
||||
protected override void OnApplyTemplate()
|
||||
{
|
||||
_notificationFlyoutPresenter = GetTemplateChild("NotificationFlyoutPresenter") as NotificationFlyoutPresenter;
|
||||
_notificationFlyoutPresenter.ApplyTemplate();
|
||||
|
||||
_notificationFlyoutPresenter.UpdateThemeVisualState(_isColorPrevalence);
|
||||
|
||||
_flyout = GetTemplateChild("Flyout") as Flyout;
|
||||
if (_flyout != null)
|
||||
{
|
||||
@@ -125,7 +133,7 @@ namespace TheXamlGuy.NotificationFlyout.Uwp.UI.Controls
|
||||
}
|
||||
|
||||
_isLoaded = true;
|
||||
SetFlyoutPlacement(_placement);
|
||||
UpdateFlyoutVisualState();
|
||||
}
|
||||
|
||||
private void OnFlyoutClosed(object sender, object args) => _notificationFlyout?.InvokeClosedEvent(args);
|
||||
@@ -135,5 +143,13 @@ namespace TheXamlGuy.NotificationFlyout.Uwp.UI.Controls
|
||||
private void OnFlyoutOpened(object sender, object args) => _notificationFlyout?.InvokeOpenedEvent(args);
|
||||
|
||||
private void OnFlyoutOpening(object sender, object args) => _notificationFlyout?.InvokeOpeningEvent(args);
|
||||
|
||||
private void UpdateFlyoutVisualState()
|
||||
{
|
||||
if (!_isLoaded) return;
|
||||
|
||||
if (string.IsNullOrEmpty(_placement)) return;
|
||||
VisualStateManager.GoToState(this, _placement, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -64,7 +64,7 @@
|
||||
</TransitionCollection>
|
||||
</Grid.Transitions>
|
||||
<controls:NotificationFlyoutPresenter
|
||||
x:Name="FlyoutPresenter"
|
||||
x:Name="NotificationFlyoutPresenter"
|
||||
Content="{TemplateBinding Content}"
|
||||
Style="{TemplateBinding FlyoutPresenterStyle}" />
|
||||
</Grid>
|
||||
|
||||
+1
-3
@@ -10,8 +10,6 @@ namespace TheXamlGuy.NotificationFlyout.Uwp.UI.Controls
|
||||
DefaultStyleKey = typeof(NotificationFlyoutPresenter);
|
||||
}
|
||||
|
||||
// protected override void OnApplyTemplate() => UpdateThemeVisualStates(false);
|
||||
|
||||
// private void UpdateThemeVisualStates(bool useTransition) => VisualStateManager.GoToState(this, _systemPersonalisationHelper.IsColorPrevalence ? "ColorPrevalenceTheme" : "DefaultTheme", useTransition);
|
||||
internal void UpdateThemeVisualState(bool isColorPrevalence) => VisualStateManager.GoToState(this, isColorPrevalence ? "ColorPrevalenceTheme" : "DefaultTheme", true);
|
||||
}
|
||||
}
|
||||
+15
-1
@@ -83,6 +83,7 @@ namespace TheXamlGuy.NotificationFlyout.Wpf.UI.Controls
|
||||
PrepareNotificationIcon();
|
||||
PrepareTaskbar();
|
||||
UpdateWindow();
|
||||
UpdateTheme();
|
||||
}
|
||||
|
||||
protected override void OnDeactivated(EventArgs args) => HideFlyout();
|
||||
@@ -106,7 +107,11 @@ namespace TheXamlGuy.NotificationFlyout.Wpf.UI.Controls
|
||||
|
||||
private void OnTaskbarChanged(object sender, EventArgs args) => UpdateWindow();
|
||||
|
||||
private void OnThemeChanged(object sender, SystemPersonalisationChangedEventArgs args) => UpdateIcons();
|
||||
private void OnThemeChanged(object sender, SystemPersonalisationChangedEventArgs args)
|
||||
{
|
||||
UpdateTheme();
|
||||
UpdateIcons();
|
||||
}
|
||||
|
||||
private void PrepareContextMenu()
|
||||
{
|
||||
@@ -175,6 +180,15 @@ namespace TheXamlGuy.NotificationFlyout.Wpf.UI.Controls
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateTheme()
|
||||
{
|
||||
var content = GetHostContent();
|
||||
if (content != null)
|
||||
{
|
||||
content.UpdateTheme(_systemPersonalisationHelper.IsColorPrevalence);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateWindow()
|
||||
{
|
||||
if (!IsLoaded) return;
|
||||
|
||||
Reference in New Issue
Block a user