microsoft / microsoft/WPF-Samples

Can't use resources/ styles set in App.xaml.cs in a WPF page (System.Windows.Controls.Page)

Open
#732 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
5.7k
Forks
3.3k
Avg merge
12d 8h
Merged PRs (30d)
2

Description

This works in a WPF window (System.Windows.Window):
<TextBlock Text="This is a Fluent styled TextBlock" Style="{StaticResource CaptionTextBlockStyle}" />

but, not in a WPF page (System.Windows.Controls.Page)

In both cases my App.xaml.cs has the following markup:
<Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/PresentationFramework.Fluent;component/Themes/Fluent.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources>

Contributor guide

No contributing guide indexed for this repository

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 Application.Resources markup in App.xaml.cs and compare how CaptionTextBlockStyle is resolved in a WPF Window versus a System.Windows.Controls.Page. Reproduce the StaticResource lookup using the Fluent.xaml merged dictionary; done when the style resolves correctly in the Page as well as the Window.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.