0

I want to make the hint text and set the hint text color in xaml textbox. Is there a way to set the hint text and hint text color in textbox at xaml file directly? Please let me know the way.

DevCaf
  • 109
  • 11
  • Does this answer your question? [How can I add a hint text to WPF textbox?](https://stackoverflow.com/questions/7425618/how-can-i-add-a-hint-text-to-wpf-textbox) – Artur Jul 03 '20 at 00:05

1 Answers1

1

I use MaterialDesignThemes. Download the NuGet and us it as follow:

xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" 

<TextBox materialDesign:HintAssist.Hint="Floating Hint" Style="{StaticResource MaterialDesignFloatingHintTextBox}" VerticalAlignment="Center"/>

You also need to make the following changes in your App.xaml

<ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Dark.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.DeepPurple.xaml" />
        </ResourceDictionary.MergedDictionaries>

MaterialDesign Getting Started

Fehr Benjamin
  • 62
  • 1
  • 11
  • Is there no way to make hint text without using material design? I made one style in windows.resource and use that as a Style. Is there a way to use 2 styles in one textbox? Anyways, Thanks for your answer. – DevCaf Jul 03 '20 at 00:23
  • I think its possible to make the hint text by yourself (as a Style), its just a easy solution. You dont need to reinvent the weel ; ) – Fehr Benjamin Jul 03 '20 at 04:48
  • Please let me know the way how to set hint text by manual. Thanks in advance. – DevCaf Jul 03 '20 at 07:29