2012-11-29 30 views
10

मेरे पास निम्नलिखित UserControl है। यह एक एक Button साथ TextBox है: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> 

विंडोज 7 में यह बहुत अच्छा है, लेकिन Windows XP में लग रहा है मैं निम्नलिखित मुद्दा है:

enter image description here

समस्या के समाधान के पर कोई भी विचार? अगर मैं पृष्ठभूमि को पारदर्शी बनाता हूं तो बटन के साथ कोई समस्या नहीं है लेकिन पाठ बटन के नीचे आता है और अजीब लग रहा है।

उत्तर

6

Button छोटे और/या दृश्यमान पृष्ठभूमि को "डाउनसाइज़" करने के लिए एक छोटा मार्जिन जोड़ें।

संपादित करें: थोड़ा सा देखते हुए (यह सोचकर कि इसे कुछ नए फीचर के रूप में नहीं जोड़ा गया है) मुझे this article with step-by-step instructions you could give a try मिला है।

+0

तो मुझे लगता है कि तब W7 पर बटन पाठ बॉक्स से छोटी है कर पा सकते हैं और जब आप/क्लिक हूवर यह भी बदसूरत लग रहा है :( –

+0

मैंने जो ब्लॉग पोस्ट जोड़ा है उसे आजमाएं। – Mario

2

मुझे लगता है कि तुम यहाँ ControlTemplate रों का उपयोग करना चाहिए, उदाहरण के रूप में आप Search Text Box Control देख सकते हैं और here आप पाठ बॉक्स टेम्पलेट