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

ItemsControl just display UserControl not ItemTemplate #17725

Open
MintOTea opened this issue Dec 9, 2024 · 1 comment
Open

ItemsControl just display UserControl not ItemTemplate #17725

MintOTea opened this issue Dec 9, 2024 · 1 comment
Labels
by-design The behavior reported in the issue is actually correct. question

Comments

@MintOTea
Copy link

MintOTea commented Dec 9, 2024

Describe the bug

ItemsControl just display UserControl not ItemTemplate

To Reproduce

I have a interface like this
image
and a UserControl extend this interface
image
image

in ItemsControl i used ItemTemplate to display a Textblock with PaneTitle property which is "as" in interface
image

It should display "as" in my ui, but it just display the content in the UserControl
image

Expected behavior

It should display "as" in my ui, but it just display the content in the UserControl
image

Avalonia version

11.2.2

OS

Windows

Additional context

No response

@MintOTea MintOTea added the bug label Dec 9, 2024
@rabbitism
Copy link
Contributor

This is not a bug.

https://github.com/AvaloniaUI/Avalonia/blob/master/src%2FAvalonia.Controls%2FItemsControl.cs#L497-L543

ItemsControl is designed to behave like this. As long as an element is a control, the container will display the control itself.

If you dont need this feature, you should derive a new class, and override this method according to your needs.

Further more, UserControl as ItemsSource in general is valid but not a good practice

@timunie timunie added question by-design The behavior reported in the issue is actually correct. and removed bug labels Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
by-design The behavior reported in the issue is actually correct. question
Projects
None yet
Development

No branches or pull requests

3 participants