Clicking a row causes NullReferenceException
Closed this issue · 3 comments
Description:
I create my columns programmatically. WHen clicking a row an unhandled nullref exception is thrown
Steps to Reproduce:
- Add a tableview:
<tableView:TableView x:Name="TableView" xmlns:tableView="using:WinUI.TableView"
AutoGenerateColumns="False" Background="White" />
- Generate columns in code-behind and assign itemssource.
- Run and click on a row.
Expected behavior:
No crash.
Screenshots:
Environment:
- Package Version:
- WinAppSDK Version:
Note
It might be worth turning on null annotations for the project to catch these (and remember that all dependency properties that aren't value types can potentially be null so add ? to those too.
Thank you, @dotMorten, for your feedback and suggestions. Regrettably, I am not encountering any exceptions when adding columns from the code behind, regardless of whether I set the ItemsSource before or after.
I appreciate your recommendation to make dependency properties nullable and will proceed to refactor the code accordingly.
Could be because I'm also using converters. I wasn't getting a good callstack - I don't think you have any source linked symbol packages that would give be better stack traces?
Correct, source link isn't available.
I tried to use converters but that wasn't helpful. It would be great if you could upload a small app where the exception can be seen.