How to apply a ThemeResource to a Textblock created during runtime #9016
Unanswered
roshannzth
asked this question in
Q&A
Replies: 1 comment
-
See #4443 and other issues linked to it |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
<TextBlock Text="Sample Text" Foreground="{ThemeResource TextFillColorSecondary}"></TextBlock>
I have a sample textblock xaml code as above.,
I want to create this control during runtime and adhere to themes on runtime.
What i tried here is
This behaves like a StaticResource which adapts to the theme once on startup.
(If i start my application in dark mode, text is in white color, and i switch to light theme, text remains in white )
I tried to create a CustomStyle.xaml and included the following resource
and added this info in App.xaml
But when i run the app, app crashes with the following error message
L"Cannot find a Resource with the Name/Key TextFillColorPrimary
Any idea what i am doing wrong, or is there a way to apply theme resource from code ?
Beta Was this translation helpful? Give feedback.
All reactions