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

Using ContentPresenter as ListViewItem template is not working #7446

Open
Arlodotexe opened this issue Nov 8, 2021 · 2 comments · May be fixed by #14692
Open

Using ContentPresenter as ListViewItem template is not working #7446

Arlodotexe opened this issue Nov 8, 2021 · 2 comments · May be fixed by #14692
Labels
area/listview 📃 Categorizes an issue or PR as relevant to the ListView control difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI kind/bug Something isn't working project/items 🧾 Categorizes an issue or PR as relevant to items (ItemsControl, ItemsRepeater, ...)

Comments

@Arlodotexe
Copy link
Contributor

Current behavior

Nothing is rendered

image

Expected behavior

Items should render the same as it does on UWP.

image

How to reproduce it (as minimally and precisely as possible)

On a ListView, set the item container style to:

<ListView.ItemContainerStyle>
    <Style TargetType="ListViewItem">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListViewItem">
                    <ContentPresenter />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ListView.ItemContainerStyle>

Minimal repro on the Uno Playground:
https://playground.platform.uno/#f419ea68

Workaround

Remove the template setter

Works on UWP/WinUI

Yes

Environment

Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia

NuGet package version(s)

Uno.UI.WebAssembly Version 3.10.11

Affected platforms

WebAssembly

IDE

Visual Studio 2022, Visual Studio 2019

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

@Arlodotexe Arlodotexe added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Nov 8, 2021
@Arlodotexe Arlodotexe changed the title Using ContentPresenter in ListViewItem not working Using ContentPresenter as ListViewItem Template not working Nov 8, 2021
@davidjohnoliver
Copy link
Contributor

You're running afoul of this issue: #857

The workaround is to explicitly bind the Content and ContentTemplate on the ContentPresenter:

                            <ControlTemplate TargetType="ListViewItem">
                                <ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" />
                            </ControlTemplate>

@Arlodotexe
Copy link
Contributor Author

You're running afoul of this issue: #857

The workaround is to explicitly bind the Content and ContentTemplate on the ContentPresenter:

                            <ControlTemplate TargetType="ListViewItem">
                                <ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" />
                            </ControlTemplate>

@davidjohnoliver So this fixed our issue on WASM, but it also causes a crash on UWP when the debugger isn't attached, somehow.

Had trouble using platform-specific code in the style setters, so we'll have to just remove the template setter for now.

@MartinZikmund MartinZikmund changed the title Using ContentPresenter as ListViewItem Template not working Using ContentPresenter as ListViewItem template is not working Jul 19, 2023
@MartinZikmund MartinZikmund added area/listview 📃 Categorizes an issue or PR as relevant to the ListView control project/items 🧾 Categorizes an issue or PR as relevant to items (ItemsControl, ItemsRepeater, ...) difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI and removed triage/untriaged Indicates an issue requires triaging or verification difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. labels Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/listview 📃 Categorizes an issue or PR as relevant to the ListView control difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI kind/bug Something isn't working project/items 🧾 Categorizes an issue or PR as relevant to items (ItemsControl, ItemsRepeater, ...)
Projects
None yet
3 participants