如何在WPF中将字符串的第一个字母输入到TextBox
到更高的字母。我想在xaml中这样做。
<TextBox x:Name="txtName" CharacterCasing="Upper"
HorizontalAlignment="Left" Height="23"
Margin="300,151,0,0" TextWrapping="Wrap"
VerticalAlignment="Top" Width="240"
Text="{Binding Name}" Grid.ColumnSpan="2"
TextChanged="txtName_TextChanged"/>
答案 0 :(得分:5)
这是诀窍的风格:
<TextBox>
<TextBox.Style>
<Style TargetType="TextBox">
<Setter Property="CharacterCasing" Value="Lower"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Text.Length, RelativeSource={RelativeSource Self}}" Value="0">
<Setter Property="CharacterCasing" Value="Upper"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>