2010-07-25 10 views
6

मैं वस्तुओं के बीच रिक्त स्थान/पैडिंग बढ़ाने के लिए एक combobox के XAML टेम्पलेट को लिखना चाहता हूं। मैं इस के लिए खोज की, लेकिन लगभग ItemsPresenter साथ अंत:पैडिंग प्रदर्शित आइटम combobox कैसे बढ़ाएं?

<ItemsPresenter x:Name="ItemsPresenter" 
       KeyboardNavigation.DirectionalNavigation="Contained" 
       SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/> 

मैं मद (सीमा, पैडिंग, फ़ॉन्ट ...) इस टेम्पलेट का उपयोग स्वरूपित कर सकते हैं कैसे? कृपया मदद करें।

+0

मुझे इसकी भी आवश्यकता है! आप सभी लोगों से सुनने के लिए तत्पर हैं। –

उत्तर

8

आप ItemContainerStyle उपयोग कर सकते हैं कि इस तरह के ComboBoxItems गद्दी के रूप में गुण सेट करने के लिए शैली लागू करना:

<ComboBox ItemsSource="{Binding}"> 
    <ComboBox.ItemContainerStyle> 
     <Style TargetType="ComboBoxItem"> 
      <Setter Property="Padding" Value="5"/> 
      <Setter Property="BorderBrush" Value="Blue"/> 
      <Setter Property="BorderThickness" Value="2"/> 
      <Setter Property="FontFamily" Value="Courier New"/> 
     </Style> 
    </ComboBox.ItemContainerStyle> 
</ComboBox> 

आप यह सब कॉम्बो बक्से पर लागू करना चाहते हैं, तो आप के बजाय में ComboBoxItem के लिए एक अंतर्निहित शैली बना सकते हैं आपके संसाधन:

<Window.Resources> 
    <Style TargetType="ComboBoxItem"> 
     <Setter Property="Padding" Value="5"/> 
    </Style> 
</Window.Resources> 
<StackPanel> 
    <ComboBox ItemsSource="{Binding}"/> 
    <ComboBox ItemsSource="{Binding}"/> 
</StackPanel> 
संबंधित मुद्दे