Open Axemasta opened 2 months ago
Hi I'm an AI powered bot that finds similar issues based off the issue title.
Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!
Note: You can give me feedback by thumbs upping or thumbs downing this comment.
I can repro this issue at Windows platform on the latest 17.12.0 Preview 1.0(8.0.80 & 8.0.72). Sample project: https://github.com/Axemasta/TouchBehaviorRelativeSource/tree/appthemebinding
I've looked into this running maui locally. It looks like the OnAppThemeChanged
listener is never invoked for the behavior (only, everything else works). If I manually add a call to RequestedThemeChanged
, this starts working again so I'll investigate further as to why it doesn't apply to the behavior!
public AppThemeProxy(Element parent, AppThemeBinding binding)
{
_parent = parent;
Binding = binding;
this.SetDynamicResource(AppThemeProperty, AppThemeResource);
((IElementDefinition)parent)?.AddResourcesChangedListener(OnParentResourcesChanged);
if (Application.Current is not null)
{
Application.Current.RequestedThemeChanged += (s, e) =>
{
OnAppThemeChanged();
};
}
}
Description
This is another issue with the TouchBehavior which is affecting users.
I have been able to replicate the issue outside of the
TouchBehavior
so I will report it seperately.Given the following
PlatformBehavior
:If we use an app theme binding to set the
Color
property:When we navigate to a page that uses this behavior, the correct color will be set based on the app theme:
Colors.Blue
Colors.Red
This doesn't work if the app theme changes at runtime. The old value will be used:
Colors.Blue
Colors.Blue
Hooking into the theme changed api, we can respond to changes in theme however the value of the property does not change. Its also worth noting that the property changed events that handle changing the color do not fire when the theme is switched, it only happens if you manually hook the theme changes.
Since there are no warnings or exceptions available, its hard to know why this isn't happening.
Steps to Reproduce
Either run the repro provided or:
using PlatformView = Android.Views.View;
elif WINDOWS
using PlatformView = Microsoft.UI.Xaml.FrameworkElement;
elif TIZEN
using PlatformView = Tizen.NUI.BaseComponents.View;
elif NET6_0_OR_GREATER || (NETSTANDARD || !PLATFORM)
using PlatformView = System.Object;
endif
using System.Diagnostics;
namespace TouchBehaviorRelativeBinding.Behaviors;
public partial class ColorBehavior : PlatformBehavior
{
public static readonly BindableProperty ColorProperty = BindableProperty.Create(
nameof(Color),
typeof(Color),
typeof(ColorBehavior),
null ,
propertyChanged: UpdateColor);
}