MSDN lists the styles and patterns for the TextBox class here . I can override these theme resources by creating a ResourceDictionary in App.xaml as follows:
<Application.Resources> <ResourceDictionary> <ResourceDictionary.ThemeDictionaries> <ResourceDictionary x:Key="Default"> <SolidColorBrush x:Key="TextBoxPlaceholderTextThemeBrush" Color="Yellow"/> </ResourceDictionary> </ResourceDictionary.ThemeDictionaries> </ResourceDictionary> </Application.Resources>
but this will affect every TextBox in my application. How to install this theme only for a specific item?
I tried to put this dictionary in Page.Resources and even TextBox.Resources for TextBox , to which I want to apply it, but it does not work.
I really don't want to override Template to change this property.
EDIT . Heena's answer is close, but I would also like to set different colors for light and dark themes, because my text box has a transparent background color.
I managed to achieve this by saving Foreground="{ThemeResource TextBoxPlaceholderTextThemeBrush}" as part of the Template (in other words, the default template complies with the MSDN standard), and then specify in the page resources:
<Page.Resources> <ResourceDictionary.ThemeDictionaries> <ResourceDictionary x:Key="Light"> <SolidColorBrush x:Key="TextBoxPlaceholderTextThemeBrush" Color="Blue"/> </ResourceDictionary> ... </ResourceDictionary.ThemeDictionaries> </Page.Resources>
but now it means that I have to put the huge ControlTemplate text editor for the text field in my page resources, which in any case is an exact duplicate by default!
Is this TextBoxPlaceholderTextThemeBrush to how TextBoxPlaceholderTextThemeBrush resolved from a ControlTemplate ? that is, why does it detect my user dictionary by having a ControlTemplate defined in the same resource dictionary?
How should this be done? Should I just subclass the text field so that all this XAML can be moved to another file (even if it is intended for only one text field)?