WPF:TextBox materialDesign - 如何对齐 HintAssist.Hint
WPF: TextBox materialDesign - how to Alignment HintAssist.Hint
所以我有这个 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"/>
我想将我的提示(在我的例子中是搜索)放在 TexBox
的中心。
我能找到的是更改 TextFieldAssist.TextBoxViewMargin
但当然这也会影响输入 text
。
只需将此代码添加到文本框:
<TextBox.Resources>
<Style TargetType="{x:Type materialDesign:SmartHint}">
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
</TextBox.Resources>
示例
<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>
所以我有这个 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"/>
我想将我的提示(在我的例子中是搜索)放在 TexBox
的中心。
我能找到的是更改 TextFieldAssist.TextBoxViewMargin
但当然这也会影响输入 text
。
只需将此代码添加到文本框:
<TextBox.Resources>
<Style TargetType="{x:Type materialDesign:SmartHint}">
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
</TextBox.Resources>
示例
<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>