TreeView - AccessViolationException with SelectedItem
See original GitHub issueThe TreeView still throws an AccessViolationException, in Microsoft.UI.Xaml 2.5.0-prerelease.200708003 despite issues #2405 and #2303 being reported as closed.
Steps to reproduce the bug Here is a sample MainPage.xaml
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
x:Class="App1.MainPage">
<StackPanel>
<muxc:TreeView ItemsSource="{x:Bind Mode=OneWay, Path=List}"
SelectedItem="{x:Bind SelectedItem}"/>
</StackPanel>
</Page>
And the code-behind MainPage.xaml.cs
namespace App1
{
public sealed partial class MainPage : Page
{
private ObservableCollection<string> List { get; set; } = new ObservableCollection<string>()
{
"Item 1",
"Item 2",
"Item 3",
};
private string SelectedItem { get; set; }
public MainPage()
{
this.InitializeComponent();
SelectedItem = List[1];
}
}
}
Steps to reproduce the behavior:
- Launch App1.
- Observe it crash with the following exception:
An unhandled exception of type 'System.AccessViolationException' occurred in App1.exe
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
The program '[9000] App1.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.
Expected behavior The app doesn’t crash and opens with the Item 2 selected.
Version Info
NuGet package version: Microsoft.UI.Xaml 2.5.0-prerelease.200708003
Windows app type:
UWP | Win32 |
---|---|
Yes |
Windows 10 version | Saw the problem? |
---|---|
Insider Build (xxxxx) | |
May 2020 Update (19041) | |
November 2019 Update (18363) | Yes |
May 2019 Update (18362) | |
October 2018 Update (17763) | |
April 2018 Update (17134) | |
Fall Creators Update (16299) | |
Creators Update (15063) |
Device form factor | Saw the problem? |
---|---|
Desktop | Yes |
Xbox | |
Surface Hub | |
IoT |
Additional context It looks like nothing has been done to specifically fix the previous issues #2405 and #2303, which were assumed to have been fixed by other changes.
This crash is pretty bad, we cannot catch the exception, and it’s critical to get to the bottom of those issues and have them fixed properly.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
The issues #2405 and #2303 were fixed by the switch away from a regular property to a dependency property for SelectedItem, as those both hit an issue where the
tracker_ref
ended up in a bad state.This bug is different to the other bugs, but is a bug none the less. @ranjeshj I would like to look into this issue.
Thanks, I have done a cursory test with the new release, and the issue didn’t manifest itself. I’ll let you know if we see this issue again.