2012-11-29 56 views
10

私は以下を持っていますUserControl。それはButtonTextBoxです: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で私は、次の問題があります。

​​

に問題を解決する方法上の任意のアイデアを?背景を透明にすると、ボタンに問題はありませんが、テキストはボタンの下にあり、奇妙に見えます。

答えて

6

Buttonを小さくして、目に見える背景を「縮小」するために小さな余白を追加します。

編集:私はthis article with step-by-step instructions you could give a tryを見つけました。ちょっと周りを見ながら(これはいくつかの新機能として追加されていないのだろうか)。

+0

を見つけることができますを見ることができ、あなたがここにControlTemplate Sを使用すべきだと思いますそれはあまりにも醜いに見えます:( –

+0

私はリンクしているブログの記事を試してください。 – Mario

2

私は例として、あなたがSearch Text Box Controlhere私はその後、W7のボタンがテキストボックスよりも小さいですし、/クリックフーバー時にそれを行う場合は、テキストボックスのテンプレート

関連する問題