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

Proposal: Support implicitly typed DataTemplate like WPF #10221

Closed
weitzhandler opened this issue Dec 9, 2024 · 2 comments
Closed

Proposal: Support implicitly typed DataTemplate like WPF #10221

weitzhandler opened this issue Dec 9, 2024 · 2 comments
Labels
feature proposal New feature proposal needs-triage Issue needs to be triaged by the area owners

Comments

@weitzhandler
Copy link
Contributor

Proposal: Support implicitly typed DataTemplate like WPF

Summary

WPF enables specifying DataTemplates to be selected based on the binding type.

This can be implemented as following:

<ItemsControl ItemsSource="{Binding Coll}">
    <ItemsControl.Resources>
        <DataTemplate DataType="{x:Type local:ClassOne}">
            <Rectangle Width="50" Height="50" Fill="Red" />
        </DataTemplate>
        <DataTemplate DataType="{x:Type local:ClassTwo}">
            <Rectangle Width="50" Height="50" Fill="Blue" />
        </DataTemplate>
    </ItemsControl.Resources>
</ItemsControl>

The ItemsControl will automatically resolve the correct DataTemplate according to the matching DataType.

Rationale

  • Easy and straight forward
  • Avoids tedious implementations and usage of DataTemplateSelector
  • This feature exists in WPF

Scope

Capability Priority
Keying DataTemplates by their type Must
Additional keying options, perhaps bool, enum, or int Could

Important Notes

Open Questions

@weitzhandler weitzhandler added the feature proposal New feature proposal label Dec 9, 2024
Copy link

github-actions bot commented Dec 9, 2024

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one. Thank you!

Open similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Dec 9, 2024
@weitzhandler
Copy link
Contributor Author

WOW! I can't believe I forgot I opened the very same issue 5 years ago!
Yup same issue indeed, gonna close.

@microsoft-github-policy-service microsoft-github-policy-service bot added needs-triage Issue needs to be triaged by the area owners and removed needs-triage Issue needs to be triaged by the area owners labels Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature proposal New feature proposal needs-triage Issue needs to be triaged by the area owners
Projects
None yet
Development

No branches or pull requests

1 participant