Closed
Description
Describe the bug
Using SettingsExpander in a WinUI application with AOT mode enabled crashes the program.
在 WinUI 应用中使用 SettingsExpander,并启用 AOT 模式,程序出现崩溃
Steps to reproduce
Method to reproduce the error:
1. Use VS2022 to create a WinUI application.
2. Add a reference to SettingsExpander and add the AOT release to the project file.
3. Replace the default code with the following code and run it
复现错误的方法:
1. 使用 VS2022 创建一个 WinUI 应用
2. 添加对于 SettingsExpander 的引用,并在项目文件中添加 AOT 发布
3. 使用以下代码替换默认的代码并运行
<controls:SettingsExpander
x:Name="ClearBrowsingDataButton"
Header="选择每次关闭浏览器时要清除的内容">
<controls:SettingsExpander.ItemTemplate>
<DataTemplate x:DataType="local:BrowserDataKind">
<controls:SettingsCard Header="{x:Bind Name}">
<ToggleSwitch IsOn="{x:Bind IsChecked, Mode=TwoWay}"/>
</controls:SettingsCard>
</DataTemplate>
</controls:SettingsExpander.ItemTemplate>
</controls:SettingsExpander>
namespace WinUIDemo
{
public class BrowserDataKind
{
public string Name { get; set; }
public bool IsChecked { get; set; } = false;
}
public sealed partial class MainWindow : Window
{
public List<BrowserDataKind> BrowserDataKindList =
[
new() { Name = "浏览历史记录" },
new() { Name = "下载历史记录" },
new() { Name = "Cookies 和其他站点数据" },
new() { Name = "缓存的图像和文件" },
new() { Name = "密码" },
new() { Name = "自动填充表单数据(包括表单和卡)" },
new() { Name = "站点权限" },
];
public MainWindow()
{
this.InitializeComponent();
ClearBrowsingDataButton.ItemsSource = BrowserDataKindList;
}
}
}
Expected behavior
The code is expected to run correctly. When I replace SettingsExpander with ListView, the code works fine, so I think it might be a bug in SettingsExpander.
预期代码能够正常运行。当我将 SettingsExpander 替换为 ListView 时,代码正常工作,因此我认为,这或许是 SettingsExpander 的 bug
Screenshots
No response
Code Platform
- UWP
- WinAppSDK / WinUI 3
- Web Assembly (WASM)
- Android
- iOS
- MacOS
- Linux / GTK
Windows Build Number
- Windows 10 1809 (Build 17763)
- Windows 10 1903 (Build 18362)
- Windows 10 1909 (Build 18363)
- Windows 10 2004 (Build 19041)
- Windows 10 20H2 (Build 19042)
- Windows 10 21H1 (Build 19043)
- Windows 10 21H2 (Build 19044)
- Windows 10 22H2 (Build 19045)
- Windows 11 21H2 (Build 22000)
- Other (specify)
Other Windows Build number
Windows 11 24H2 (Build 26100)
App minimum and target SDK version
- Windows 10, version 1809 (Build 17763)
- Windows 10, version 1903 (Build 18362)
- Windows 10, version 1909 (Build 18363)
- Windows 10, version 2004 (Build 19041)
- Windows 10, version 2104 (Build 20348)
- Windows 11, version 22H2 (Build 22000)
- Other (specify)
Other SDK version
No response
Visual Studio Version
2022
Visual Studio Build Number
17.12.3
Device form factor
Desktop
Additional context
Dependencies used in the project:
项目中使用的依赖版本:
Microsoft.WindowsAppSDK: 1.6.241114003
CommunityToolkit.WinUI.Controls.SettingsControls: 8.2.241112-preview1
Help us help you
Yes, I'd like to be assigned to work on this item.
Metadata
Metadata
Assignees
Type
Projects
Status
✅ Done