WPF--->自定义控件中添加按钮,TextBox添加Button为例
程序员文章站
2022-06-07 13:36:15
...
<Style x:Key="SearchInputBox" TargetType="{x:Type TextBox}">
<Setter Property="Height" Value="30"/>
<Setter Property="Width" Value="150"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="4*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBox Height="30" Whith="150" Grid.Column="0" Grid.ColumnSpan="2"/>
<Button Height="30" Whith="30" Grid.Column="1"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>