Possible fix when inapp theme is changed

This commit is contained in:
Daniel Clark
2021-02-09 19:08:10 +00:00
parent 732a25d03a
commit cb837f034c
10 changed files with 64 additions and 49 deletions
@@ -12,7 +12,7 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="NotificationFlyoutPresenter\NotificationFlyoutContentPresenter.xaml">
<Page Include="NotificationFlyoutPresenter\NotificationFlyoutPresenter.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
@@ -54,14 +54,10 @@
FromVerticalOffset="0" />
</TransitionCollection>
</Grid.Transitions>
<controls:NotificationFlyoutContentPresenter Content="{TemplateBinding Content}" />
<controls:NotificationFlyoutPresenter Content="{TemplateBinding Content}" />
</Grid>
</Flyout>
</FlyoutBase.AttachedFlyout>
<Border
Width="300"
Height="400"
Background="Blue" />
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="PlacementStates">
<VisualState x:Name="Bottom">
@@ -1,12 +0,0 @@
using Windows.UI.Xaml.Controls;
namespace NotificationFlyout.Uwp.UI.Controls
{
public class NotificationFlyoutContentPresenter : ContentControl
{
public NotificationFlyoutContentPresenter()
{
DefaultStyleKey = typeof(NotificationFlyoutContentPresenter);
}
}
}
@@ -0,0 +1,27 @@
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
namespace NotificationFlyout.Uwp.UI.Controls
{
public class NotificationFlyoutPresenter : ContentControl
{
public NotificationFlyoutPresenter()
{
DefaultStyleKey = typeof(NotificationFlyoutPresenter);
}
protected override void OnApplyTemplate()
{
if (GetTemplateChild("ContentPresenter") is ContentControl contentPresenter)
{
BindingOperations.SetBinding(this, RequestedThemeProperty, new Binding
{
Source = contentPresenter.Content,
Path = new PropertyPath(nameof(RequestedTheme)),
Mode = BindingMode.TwoWay
});
}
}
}
}
@@ -31,11 +31,11 @@
FallbackColor="{StaticResource SystemAccentColorDark1}"
TintColor="{StaticResource SystemAccentColorDark1}"
TintOpacity="0.8" />
<Style TargetType="controls:NotificationFlyoutContentPresenter">
<Style TargetType="controls:NotificationFlyoutPresenter">
<Setter Property="Background" Value="{ThemeResource NotificationFlyoutPresenterBackgroundBrush}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:NotificationFlyoutContentPresenter">
<ControlTemplate TargetType="controls:NotificationFlyoutPresenter">
<Border
x:Name="Root"
Padding="{TemplateBinding Padding}"
@@ -52,7 +52,8 @@
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
ZoomMode="{TemplateBinding ScrollViewer.ZoomMode}">
<ContentPresenter
<ContentControl
x:Name="ContentPresenter"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
@@ -1,7 +1,6 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHost.xaml" />
<ResourceDictionary Source="ms-appx:///NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutPresenter/NotificationFlyoutContentPresenter.xaml" />
<ResourceDictionary Source="ms-appx:///NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutPresenter/NotificationFlyoutPresenter.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
@@ -21,7 +21,7 @@ namespace NotificationFlyout.Wpf.UI.Helpers
{
_windowHandle = window.GetHandle();
var source = HwndSource.FromHwnd(_windowHandle);
HwndSource source = HwndSource.FromHwnd(_windowHandle);
source.AddHook(new HwndSourceHook(WndProc));
CreateNotificationIcon();
+4 -4
View File
@@ -44,8 +44,8 @@ Global
{0A782234-DC9F-4C4A-8820-FC640B03D233}.Release|ARM.Build.0 = Release|Any CPU
{0A782234-DC9F-4C4A-8820-FC640B03D233}.Release|ARM64.ActiveCfg = Release|Any CPU
{0A782234-DC9F-4C4A-8820-FC640B03D233}.Release|ARM64.Build.0 = Release|Any CPU
{0A782234-DC9F-4C4A-8820-FC640B03D233}.Release|x64.ActiveCfg = Release|Any CPU
{0A782234-DC9F-4C4A-8820-FC640B03D233}.Release|x64.Build.0 = Release|Any CPU
{0A782234-DC9F-4C4A-8820-FC640B03D233}.Release|x64.ActiveCfg = Release|x64
{0A782234-DC9F-4C4A-8820-FC640B03D233}.Release|x64.Build.0 = Release|x64
{0A782234-DC9F-4C4A-8820-FC640B03D233}.Release|x86.ActiveCfg = Release|Any CPU
{0A782234-DC9F-4C4A-8820-FC640B03D233}.Release|x86.Build.0 = Release|Any CPU
{9987B132-E42C-401A-9AD5-E62529FACA40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
@@ -84,8 +84,8 @@ Global
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|ARM.Build.0 = Release|Any CPU
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|ARM64.ActiveCfg = Release|Any CPU
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|ARM64.Build.0 = Release|Any CPU
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|x64.ActiveCfg = Release|Any CPU
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|x64.Build.0 = Release|Any CPU
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|x64.ActiveCfg = Release|x64
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|x64.Build.0 = Release|x64
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|x86.ActiveCfg = Release|Any CPU
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection