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

[C# Markup] ItemsRepeater crashes when used with ItemTemplateSelector #2407

Closed
MartinZikmund opened this issue Jul 2, 2024 Discussed in #2404 · 2 comments
Closed

[C# Markup] ItemsRepeater crashes when used with ItemTemplateSelector #2407

MartinZikmund opened this issue Jul 2, 2024 Discussed in #2404 · 2 comments
Assignees

Comments

@MartinZikmund
Copy link
Member

Discussed in #2404

Originally posted by kucint July 1, 2024
ItemTemplateSelector works fine with ListView, but it crashes with ItemsRepeater:

public sealed partial class MainPage : Page
{
    public MainPage() => this
        .DataContext(new BindableMainPageModel(), (page, vm) => page
        .Background(ThemeResource.Get<Brush>("ApplicationPageBackgroundThemeBrush"))
        .Content(new StackPanel()
        .VerticalAlignment(VerticalAlignment.Center)
        .HorizontalAlignment(HorizontalAlignment.Center)
        .Children(
            new TextBlock()
            .Text("Hello Uno Platform!"),
            //new ListView()                             // ItemTemplateSelector works fine with ListView
            new ItemsRepeater()                          // but it crashes with ItemsRepeater
            .ItemsSource(() => vm.Items)
            .ItemTemplateSelector<Item>((item, selector) => selector
                .Default(() => new TextBlock().Text("def"))
                .Case<ItemA>(itemA => new TextBlock().Text("a"))
                .Case<ItemB>(itemB => new TextBlock().Text("b"))
        )));
}

on net8.0-desktop;
An exception of type 'System.ArgumentException' occurred in Uno.UI.dll but was not handled in user code

on net8.0-windows10.0.19041:
An exception of type 'System.InvalidCastException' occurred in WinRT.Runtime.dll but was not handled in user code

"Uno.Sdk": "5.2.175"

  <PropertyGroup>
    <UnoExtensionsVersion>4.1.24</UnoExtensionsVersion>
    <UnoToolkitVersion>6.0.18</UnoToolkitVersion>
    <UnoThemesVersion>5.0.13</UnoThemesVersion>
    <UnoCSharpMarkupVersion>5.2.14</UnoCSharpMarkupVersion>
  </PropertyGroup>

repro: UnoTemplateSelectorApp.zip

@dansiegel dansiegel self-assigned this Jul 2, 2024
@dansiegel
Copy link
Contributor

dansiegel commented Jul 8, 2024

@kucint this fix has been merged and should be available in the latest preview version. Please let me know if you have any further issues with this.

Also note that this will be backported to the 5.3 branch and will be in the upcoming 5.3 release.

@kucint
Copy link

kucint commented Jul 10, 2024

@kucint this fix has been merged and should be available in the latest preview version. Please let me know if you have any further issues with this.

Also note that this will be backported to the 5.3 branch and will be in the upcoming 5.3 release.

Hi @dansiegel
This fix must be something big, it seems that it fixed as well other issues related to ItemsRepeater I observed from time to time in my app but I could not find any stable repro pattern for them, so I did not report them. Now they all seem to be gone.
BTW, it has been already backported to 5.2, right?

Thanks for this fix, now I have impression that the implementation of ItemsRepeater is becoming stable!
Well done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants