So I have this TexBox
:
<TextBox Height="30"
BorderThickness="0"
materialDesign:TextFieldAssist.HasFilledTextField="False"
materialDesign:TextFieldAssist.HasOutlinedTextField="False"
materialDesign:TextFieldAssist.DecorationVisibility="Hidden"
materialDesign:TextFieldAssist.UnderlineBrush="Transparent"
materialDesign:TextFieldAssist.TextBoxViewMargin="10,3,0,0"
materialDesign:TextFieldAssist.HasClearButton="True"
materialDesign:HintAssist.Hint="Search"
materialDesign:HintAssist.HelperTextFontSize="12"
materialDesign:HintAssist.IsFloating="False"/>
And I want to place my Hint (Search in my example) at the center of my TexBox
.
Al i can found is to change TextFieldAssist.TextBoxViewMargin
but of course this effect the input text
as well.
CodePudding user response:
Just add this code to textbox:
<TextBox.Resources>
<Style TargetType="{x:Type materialDesign:SmartHint}">
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
</TextBox.Resources>
Example
<TextBox Height="30"
BorderThickness="0"
materialDesign:TextFieldAssist.HasFilledTextField="False"
materialDesign:TextFieldAssist.HasOutlinedTextField="False"
materialDesign:TextFieldAssist.DecorationVisibility="Hidden"
materialDesign:TextFieldAssist.UnderlineBrush="Transparent"
materialDesign:TextFieldAssist.TextBoxViewMargin="10,3,0,0"
materialDesign:TextFieldAssist.HasClearButton="True"
materialDesign:HintAssist.Hint="Search"
materialDesign:HintAssist.HelperTextFontSize="12"
materialDesign:HintAssist.IsFloating="False">
<TextBox.Resources>
<Style TargetType="{x:Type materialDesign:SmartHint}">
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
</TextBox.Resources>
</TextBox>