dotnet / dotnet/wpf

Style doesn't work for controls that were defined inside DataTemplate

Open
#9,029 0 comments 2 reactions 0 assignees View on GitHub
Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Description

In our application, we have customized the style of Hyperlink and TextBlock and merged it to Window resources. But, respective style not apply for the hyperlink and textblock controls that were defined inside the DataTemplate.

![image](https://github.com/dotnet/wpf/assets/92976485/f580cff0-13a7-460a-a014-224067002227)

But suppose if we merge the resource dictionary in Application resources. It works fine.
![image](https://github.com/dotnet/wpf/assets/92976485/0b413535-6211-41b9-859c-3e77383ad402)

### Reproduction Steps

1. Note, we have merged resource dictionary in Windows.Resources.
2. Run the sample.
3. Note, Hyperlink and TextBlock style not applied.

[Style-issue.zip](https://github.com/dotnet/wpf/files/14996898/Style-issue.zip)

### Expected behavior

Style should work for controls that were defined inside DataTemplate

### Actual behavior

Style doesn't work for controls that were defined inside DataTemplate

### Regression?

_No response_

### Known Workarounds

_No response_

### Impact

_No response_

### Configuration

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.