ContentDialog Used ContentTemplateSelector Not Work
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 9.6k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
I want to use a ContentDialog to display multiple different contents, so I set ContentTemplateSelector but it doesn't execute the SelectTemplate method
To Reproduce
Follow the example in Wpf.Ui.Gallery to create a control based on ContentDialog and set the ContentTemplateSelector property.
The SelectTemplate method of ContentTemplateSelector was not executed when I set the DataContext.
Make sure the ContentTemplateSelector is correct
The SelectTemplate method is executed when I remove
<ui:ContentDialog.Resources>
<Style BasedOn="{StaticResource {x:Type ui:ContentDialog}}" TargetType="{x:Type local:DropEditDialog}" />
</ui:ContentDialog.Resources>
Expected behavior
The SelectTemplate method of ContentTemplateSelector should be executed
Screenshots
No response
OS version
Windows11
.NET version
7
WPF-UI NuGet version
WPF UI - Development
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Wpf.Ui.Gallery ContentDialog example and the ContentDialog.Resources style shown in the report; reproduce the case with a ContentTemplateSelector and a DataContext. Trace why SelectTemplate is skipped when the derived dialog style is present, and verify that the selector executes while the style remains applied.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100