lepoco / lepoco/wpfui

ContentDialog Used ContentTemplateSelector Not Work

Open
#580 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.