をoveridingせずに、私は以下のコードでテンプレートをオーバーライドするテキストボックスにボタンを実装し、テキストボックスの機能のボタンを与える:は、カスタムコントロールを使用しますが、テキストボックスのテンプレート
<Style x:Key="{x:Type TextBox}" TargetType="{x:Type TextBoxBase}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBoxBase}">
<Border Name="Border"
CornerRadius="2"
Padding="2"
Background="{StaticResource WindowBackgroundBrush}"
BorderBrush="{StaticResource SolidBorderBrush}"
BorderThickness="1">
<Grid x:Name="LayoutGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ScrollViewer x:Name="PART_ContentHost" Grid.Column="0" />
<Button x:Name="XButton"
Grid.Column="2"
Width="25"
Height="25"
Content="X"
Visibility="Visible"
BorderBrush="Transparent"
Command="{Binding ButtonClick}" />
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
ボタンはすべてのコンテンツを削除する必要がありますテキストボックスにヒットするとこれについては、コマンド "Command =" {Binding ButtonClick} ""
を使用したいと思いますか?カスタムコントロールとライブラリを作成せずにバインドできますか? またはバインディングや機能をどのように行うことができますか?
私はMVVMパターンを使用しています。たとえば、ViewModelを使用して、それをバインドするプロパティを作成する方法がありますか?そのようなスタイルでのバインディングのために