Possible fix when inapp theme is changed
This commit is contained in:
@@ -7,6 +7,11 @@
|
||||
Width="330"
|
||||
Height="500"
|
||||
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" />
|
||||
<Slider Margin="0,0,0,8" />
|
||||
<TextBox Margin="0,0,0,8" />
|
||||
|
||||
@@ -1,27 +1,26 @@
|
||||
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
|
||||
namespace NotificationFlyoutSample
|
||||
{
|
||||
public sealed partial class Shell : UserControl
|
||||
public sealed partial class 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>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="NotificationFlyoutPresenter\NotificationFlyoutContentPresenter.xaml">
|
||||
<Page Include="NotificationFlyoutPresenter\NotificationFlyoutPresenter.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
|
||||
+1
-5
@@ -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">
|
||||
|
||||
-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}"
|
||||
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();
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user