Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty PropertyPath doesn't work in columns #42

Open
dotMorten opened this issue Sep 4, 2024 · 1 comment
Open

Empty PropertyPath doesn't work in columns #42

dotMorten opened this issue Sep 4, 2024 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@dotMorten
Copy link

Description:

Can't bind to the object itself using an empty or null property path.

Steps to Reproduce:

Create a column like this:

TableView.Columns.Add(new TableViewTextColumn() { Header = "Header 1", Binding = new Binding() { Path = new PropertyPath(""), Converter = converter, ConverterParameter = "fieldName" } });
TableView.Columns.Add(new TableViewTextColumn() { Header = "Header 2", Binding = new Binding() { Path = new PropertyPath(), Converter = converter, ConverterParameter = "fieldName2" } });

Throws:

System.NullReferenceException: 'Object reference not set to an instance of an object.'
This exception was originally thrown at this call stack:
    WinUI.TableView.TableViewColumnHeader.OnApplyTemplate()
    Microsoft.UI.Xaml.FrameworkElement.Microsoft.UI.Xaml.IFrameworkElementOverrides.OnApplyTemplate()
    ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_OnApplyTemplate_2(nint)
    WinRT.ExceptionHelpers.ThrowExceptionForHR.__Throw|38_0(int)
    ABI.Microsoft.UI.Xaml.IUIElementMethods.Measure(WinRT.IObjectReference, Windows.Foundation.Size)
    Microsoft.UI.Xaml.UIElement.Measure(Windows.Foundation.Size)
    WinUI.TableView.TableViewHeaderRow.CalculateHeaderWidths.AnonymousMethod__4(WinUI.TableView.TableViewColumn)
    System.Linq.Enumerable.SelectListIterator<TSource, TResult>.MoveNext()
    System.Linq.Enumerable.Sum<TSource, TResult>(System.Collections.Generic.IEnumerable<TSource>)
    WinUI.TableView.TableViewHeaderRow.CalculateHeaderWidths()
    ...
    [Call Stack Truncated]

Expected behavior:

Binds to the entire row element, so it can be passed on to the converter.

Screenshots:

If applicable, add screenshots to help explain your problem.

Environment:

  • Package Version: 1.2.0
  • WinAppSDK Version: 1.6exp2
@dotMorten dotMorten added the bug Something isn't working label Sep 4, 2024
@dotMorten dotMorten changed the title Empty PropertyPath doesn't work Empty PropertyPath doesn't work in columns Sep 4, 2024
@w-ahmad
Copy link
Owner

w-ahmad commented Sep 9, 2024

Thank you, @dotMorten, for your feedback. While a null check can resolve this issue, a crash may occur if sorting or filtering is applied to the column. Currently, the sorting and filtering do not account for value converters from the binding. I'm considering some adjustments in the sorting and filtering logic to incorporate values converted by the converters before use. Hopefully this will be available in the next release.

@w-ahmad w-ahmad added this to the v1.3.0 milestone Oct 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants