2012-11-29 157 views
10

我有以下UserControl。这是一个TextBoxButton如何实现与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 7中,它看起来不错,但在Windows XP中,我有以下问题:

​​

关于如何解决这个问题的任何想法?如果我让背景透明再有就是与按钮没有问题,但文字得到下面的按钮,看起来怪怪的。

回答

6

使Button更小和/或添加一个小的余量以“缩小”可见背景。

编辑:虽然环顾了一下(想知道这还没有被添加为一些新功能),我发现this article with step-by-step instructions you could give a try

+0

如果我这样做,那么在W7的按钮比文本更小,当你胡佛/点击它看起来太丑陋:( –

+0

尝试博客文章我联系。 – Mario

相关问题