Possible fix when inapp theme is changed
This commit is contained in:
@@ -7,6 +7,11 @@
|
|||||||
Width="330"
|
Width="330"
|
||||||
Height="500"
|
Height="500"
|
||||||
Margin="24">
|
Margin="24">
|
||||||
|
<ComboBox x:Name="Theme" SelectionChanged="Theme_SelectionChanged">
|
||||||
|
<ComboBoxItem Content="Default" />
|
||||||
|
<ComboBoxItem Content="Dark" />
|
||||||
|
<ComboBoxItem Content="Light" />
|
||||||
|
</ComboBox>
|
||||||
<Button Margin="0,0,0,8" Content="Button" />
|
<Button Margin="0,0,0,8" Content="Button" />
|
||||||
<Slider Margin="0,0,0,8" />
|
<Slider Margin="0,0,0,8" />
|
||||||
<TextBox Margin="0,0,0,8" />
|
<TextBox Margin="0,0,0,8" />
|
||||||
|
|||||||
@@ -1,27 +1,26 @@
|
|||||||
using System;
|
namespace NotificationFlyoutSample
|
||||||
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 Shell : UserControl
|
public sealed partial class Shell
|
||||||
{
|
{
|
||||||
public Shell()
|
public Shell()
|
||||||
{
|
{
|
||||||
this.InitializeComponent();
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Theme_SelectionChanged(object sender, Windows.UI.Xaml.Controls.SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
switch (Theme.SelectedIndex)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
RequestedTheme = Windows.UI.Xaml.ElementTheme.Default;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
RequestedTheme = Windows.UI.Xaml.ElementTheme.Dark;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
RequestedTheme = Windows.UI.Xaml.ElementTheme.Light;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="NotificationFlyoutPresenter\NotificationFlyoutContentPresenter.xaml">
|
<Page Include="NotificationFlyoutPresenter\NotificationFlyoutPresenter.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
|||||||
+1
-5
@@ -54,14 +54,10 @@
|
|||||||
FromVerticalOffset="0" />
|
FromVerticalOffset="0" />
|
||||||
</TransitionCollection>
|
</TransitionCollection>
|
||||||
</Grid.Transitions>
|
</Grid.Transitions>
|
||||||
<controls:NotificationFlyoutContentPresenter Content="{TemplateBinding Content}" />
|
<controls:NotificationFlyoutPresenter Content="{TemplateBinding Content}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Flyout>
|
</Flyout>
|
||||||
</FlyoutBase.AttachedFlyout>
|
</FlyoutBase.AttachedFlyout>
|
||||||
<Border
|
|
||||||
Width="300"
|
|
||||||
Height="400"
|
|
||||||
Background="Blue" />
|
|
||||||
<VisualStateManager.VisualStateGroups>
|
<VisualStateManager.VisualStateGroups>
|
||||||
<VisualStateGroup x:Name="PlacementStates">
|
<VisualStateGroup x:Name="PlacementStates">
|
||||||
<VisualState x:Name="Bottom">
|
<VisualState x:Name="Bottom">
|
||||||
|
|||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
using Windows.UI.Xaml.Controls;
|
|
||||||
|
|
||||||
namespace NotificationFlyout.Uwp.UI.Controls
|
|
||||||
{
|
|
||||||
public class NotificationFlyoutContentPresenter : ContentControl
|
|
||||||
{
|
|
||||||
public NotificationFlyoutContentPresenter()
|
|
||||||
{
|
|
||||||
DefaultStyleKey = typeof(NotificationFlyoutContentPresenter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+27
@@ -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
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-3
@@ -31,11 +31,11 @@
|
|||||||
FallbackColor="{StaticResource SystemAccentColorDark1}"
|
FallbackColor="{StaticResource SystemAccentColorDark1}"
|
||||||
TintColor="{StaticResource SystemAccentColorDark1}"
|
TintColor="{StaticResource SystemAccentColorDark1}"
|
||||||
TintOpacity="0.8" />
|
TintOpacity="0.8" />
|
||||||
<Style TargetType="controls:NotificationFlyoutContentPresenter">
|
<Style TargetType="controls:NotificationFlyoutPresenter">
|
||||||
<Setter Property="Background" Value="{ThemeResource NotificationFlyoutPresenterBackgroundBrush}" />
|
<Setter Property="Background" Value="{ThemeResource NotificationFlyoutPresenterBackgroundBrush}" />
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<ControlTemplate TargetType="controls:NotificationFlyoutContentPresenter">
|
<ControlTemplate TargetType="controls:NotificationFlyoutPresenter">
|
||||||
<Border
|
<Border
|
||||||
x:Name="Root"
|
x:Name="Root"
|
||||||
Padding="{TemplateBinding Padding}"
|
Padding="{TemplateBinding Padding}"
|
||||||
@@ -52,7 +52,8 @@
|
|||||||
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
|
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
|
||||||
VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
|
VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
|
||||||
ZoomMode="{TemplateBinding ScrollViewer.ZoomMode}">
|
ZoomMode="{TemplateBinding ScrollViewer.ZoomMode}">
|
||||||
<ContentPresenter
|
<ContentControl
|
||||||
|
x:Name="ContentPresenter"
|
||||||
Margin="{TemplateBinding Padding}"
|
Margin="{TemplateBinding Padding}"
|
||||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
<ResourceDictionary
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="ms-appx:///NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHost.xaml" />
|
<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.MergedDictionaries>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
@@ -21,7 +21,7 @@ namespace NotificationFlyout.Wpf.UI.Helpers
|
|||||||
{
|
{
|
||||||
_windowHandle = window.GetHandle();
|
_windowHandle = window.GetHandle();
|
||||||
|
|
||||||
var source = HwndSource.FromHwnd(_windowHandle);
|
HwndSource source = HwndSource.FromHwnd(_windowHandle);
|
||||||
source.AddHook(new HwndSourceHook(WndProc));
|
source.AddHook(new HwndSourceHook(WndProc));
|
||||||
|
|
||||||
CreateNotificationIcon();
|
CreateNotificationIcon();
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ Global
|
|||||||
{0A782234-DC9F-4C4A-8820-FC640B03D233}.Release|ARM.Build.0 = Release|Any CPU
|
{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.ActiveCfg = Release|Any CPU
|
||||||
{0A782234-DC9F-4C4A-8820-FC640B03D233}.Release|ARM64.Build.0 = 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.ActiveCfg = Release|x64
|
||||||
{0A782234-DC9F-4C4A-8820-FC640B03D233}.Release|x64.Build.0 = Release|Any CPU
|
{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.ActiveCfg = Release|Any CPU
|
||||||
{0A782234-DC9F-4C4A-8820-FC640B03D233}.Release|x86.Build.0 = 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
|
{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|ARM.Build.0 = Release|Any CPU
|
||||||
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|ARM64.ActiveCfg = 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|ARM64.Build.0 = Release|Any CPU
|
||||||
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|x64.ActiveCfg = Release|Any CPU
|
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|x64.ActiveCfg = Release|x64
|
||||||
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|x64.Build.0 = Release|Any CPU
|
{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.ActiveCfg = Release|Any CPU
|
||||||
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|x86.Build.0 = Release|Any CPU
|
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
|||||||
Reference in New Issue
Block a user