私は以下を持っていますUserControl
。それはButton
とTextBox
です:Windows 7のwpfにクリアボタン付きのテキストボックスを実装するにはどうすればよいですか?
<Grid>
<TextBox
Grid.Column="0"
Text="{Binding Text,
RelativeSource={RelativeSource AncestorType=UserControl},
UpdateSourceTrigger=PropertyChanged}"
x:Name="TextBox" />
<Button
Background="{Binding Background, ElementName=TextBox}"
Grid.Column="1"
Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
HorizontalAlignment="Right"
Visibility="{Binding IsClearButtonVisible,
RelativeSource={RelativeSource AncestorType=UserControl},
Converter={StaticResource BooleanToVisibilityConverter}}"
Command="{Binding ClearTextCommand,
RelativeSource={RelativeSource AncestorType=UserControl}}"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center" >
<Button.Content>
<Image
Source="{StaticResource Delete2}"
Stretch="None"
RenderOptions.BitmapScalingMode="NearestNeighbor"
VerticalAlignment="Center"
HorizontalAlignment="Center" />
</Button.Content>
</Button>
</Grid>
それは偉大に見えますが、Windows XPで私は、次の問題があります。
に問題を解決する方法上の任意のアイデアを?背景を透明にすると、ボタンに問題はありませんが、テキストはボタンの下にあり、奇妙に見えます。
を見つけることができますを見ることができ、あなたがここに
ControlTemplate
Sを使用すべきだと思いますそれはあまりにも醜いに見えます:( –私はリンクしているブログの記事を試してください。 – Mario