Avalonia,样式在更改时不更新
阿瓦洛尼亚做了一些奇怪的事情
使用 AvaloniaApp 模板
public void ToggleTheme(object? sender, RoutedEventArgs e)
{
Debug.WriteLine("Mode: " + App.Fluent.Mode.ToString() + " Styles[0]: " + Application.Current!.Styles[0].ToString());
if (App.Fluent.Mode == FluentThemeMode.Dark)
{
App.Fluent.Mode = FluentThemeMode.Light;
}
else if (App.Fluent.Mode == FluentThemeMode.Light)
{
App.Fluent.Mode = FluentThemeMode.Dark;
}
Application.Current!.Styles[0] = App.Fluent;
Application.Current.Styles[1] = App.DataGridFluent;
}
单击我的按钮即可获得它
调试输出
Mode: Dark Styles[0]: Avalonia.Themes.Fluent.FluentTheme
Mode: Light Styles[0]: Avalonia.Themes.Fluent.FluentTheme
Mode: Dark Styles[0]: Avalonia.Themes.Fluent.FluentTheme
Mode: Light Styles[0]: Avalonia.Themes.Fluent.FluentTheme
我需要重新加载一些东西吗?
https://github.dev/AvaloniaUI/Avalonia/tree/master/samples/控制目录
使用的代码,将其从组合框更改为按钮
顺便说一句,有人知道 Avalonia.Default 是怎么回事吗?
默认样式还没有实现模式吗?
该事件似乎没有在列表中触发,我可以使用外部解决方法吗?
Application.Current.Styles.CollectionChanged += (s, e) => Debug.WriteLine("Updated");
我可以从外部修改列表以引发项目更改事件吗?
public override void Initialize()
{
Styles.Insert(0, Fluent);
Styles.Insert(1, DataGridFluent);
AvaloniaXamlLoader.Load(this);
}
https://github.com/AvaloniaUI/Avalonia/issues/3495 发现了这个问题,不过据说已经修复了
Avalonia doing something odd
using AvaloniaApp template
public void ToggleTheme(object? sender, RoutedEventArgs e)
{
Debug.WriteLine("Mode: " + App.Fluent.Mode.ToString() + " Styles[0]: " + Application.Current!.Styles[0].ToString());
if (App.Fluent.Mode == FluentThemeMode.Dark)
{
App.Fluent.Mode = FluentThemeMode.Light;
}
else if (App.Fluent.Mode == FluentThemeMode.Light)
{
App.Fluent.Mode = FluentThemeMode.Dark;
}
Application.Current!.Styles[0] = App.Fluent;
Application.Current.Styles[1] = App.DataGridFluent;
}
got it as a click to my button
debug output
Mode: Dark Styles[0]: Avalonia.Themes.Fluent.FluentTheme
Mode: Light Styles[0]: Avalonia.Themes.Fluent.FluentTheme
Mode: Dark Styles[0]: Avalonia.Themes.Fluent.FluentTheme
Mode: Light Styles[0]: Avalonia.Themes.Fluent.FluentTheme
do i have to reload something?
https://github.dev/AvaloniaUI/Avalonia/tree/master/samples/ControlCatalog
code used, changed it from Combobox to button
btw anyone knows what's up with Avalonia.Default?
Are Default styles still not Mode implemented?
It seems that the event is not firing on the list, is there outside workaround i could use?
Application.Current.Styles.CollectionChanged += (s, e) => Debug.WriteLine("Updated");
Can I modify the list from outside to raise an event on item change?
public override void Initialize()
{
Styles.Insert(0, Fluent);
Styles.Insert(1, DataGridFluent);
AvaloniaXamlLoader.Load(this);
}
https://github.com/AvaloniaUI/Avalonia/issues/3495
Found this issue but it is said to be fixed
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论