2012-11-29 80 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

相關問題