将图标添加到 WPF TextBox 控件中
Add icon into WPF TextBox control
有没有人有 xaml 如何在 WPF 中的 TextBox 控件中添加图标的示例?
我特别是在将图标叠加到 TextBox 控件的右侧之后,但我不确定该怎么做
谢谢!
这是一个例子,如果你想用相同的 Template
影响你所有的 TextBox
,你可以把它放在 Style
中。
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBox Text="Test">
<TextBox.Template>
<ControlTemplate TargetType="{x:Type TextBox}">
<Grid>
<TextBox Text="{TemplateBinding Text}"/>
<Image Margin="0,0,5,0"
Source="http://fakeimg.pl/12x12/"
Width="12"
Height="12"
HorizontalAlignment="Right"/>
</Grid>
</ControlTemplate>
</TextBox.Template>
</TextBox>
</Grid>
有没有人有 xaml 如何在 WPF 中的 TextBox 控件中添加图标的示例?
我特别是在将图标叠加到 TextBox 控件的右侧之后,但我不确定该怎么做
谢谢!
这是一个例子,如果你想用相同的 Template
影响你所有的 TextBox
,你可以把它放在 Style
中。
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBox Text="Test">
<TextBox.Template>
<ControlTemplate TargetType="{x:Type TextBox}">
<Grid>
<TextBox Text="{TemplateBinding Text}"/>
<Image Margin="0,0,5,0"
Source="http://fakeimg.pl/12x12/"
Width="12"
Height="12"
HorizontalAlignment="Right"/>
</Grid>
</ControlTemplate>
</TextBox.Template>
</TextBox>
</Grid>