2011-08-24 15 views
7

के लिए CornerRadius साथ सीमा संपत्ति को अनुकूलित मैं CornerRadius के साथ सीमा के निम्न लिस्टबॉक्स-प्रदर्शन संपत्ति को अनुकूलित करना चाहते हैं = 5..can किसी को भी मेरी मदद निम्नलिखित Xaml कोड में मौजूदा DataTemplate कोड बदले बिना इसे प्राप्त करने के:ListBox

<ListBox x:Uid="lst_value" Name="lstValues" Background="Wheat" BorderBrush="Black" 
     HorizontalAlignment="Left" VerticalAlignment="Top" BorderThickness="1" Height="100" Width="150" 
     ItemsSource="{Binding listval}" > 
    <ListBox.ItemTemplate> 
     <DataTemplate> 
      <StackPanel Orientation="Vertical" Background="{Binding}"> 
       <TextBlock x:Name="txtblk" Foreground="Black" FontSize="10" TextAlignment="Left" 
               FontWeight="Black" Text="{Binding}" Background="{Binding}"></TextBlock> 
      </StackPanel> 
     </DataTemplate> 
    </ListBox.ItemTemplate> 
</ListBox> 

उत्तर

10

आप ListBoxItems भीतर Border चाहते हैं एक और CornerRadius मूल्य के लिए, आप कर सकते हैं या तो फिर से टेम्पलेट ListBoxItem जहां Border परिभाषित है, या यह परोक्ष सेट ItemContainerStyle संसाधन में है

<ListBox ...> 
    <ListBox.ItemContainerStyle> 
     <Style TargetType="ListBoxItem"> 
      <Style.Resources> 
       <Style TargetType="Border"> 
        <Setter Property="CornerRadius" Value="5"/> 
       </Style> 
      </Style.Resources> 
     </Style> 
    </ListBox.ItemContainerStyle> 
    <!--...--> 
</ListBox> 

संपादित करें: आप ListBox के लिए CornerRadius सेट करना चाहते हैं, तो आप भी ऐसा कर सकते हैं लेकिन Resources में बजाय

<ListBox ...> 
     <ListBox.Resources> 
      <Style TargetType="Border"> 
       <Setter Property="CornerRadius" Value="10"/> 
      </Style> 
     </ListBox.Resources> 
    <!--...--> 
</ListBox> 
+0

हाँ, हम लिस्टबॉक्स अंदर एक सीमा हर ListItem ... जहां के रूप में के लिए हो सकता है मुझे पूरे सूची बॉक्स के लिए कॉर्नरेडियस के साथ सीमा संपत्ति की आवश्यकता है .... उम्मीद है कि मेरे प्रश्न के साथ स्पष्ट हो .. –

+0

तो आप 'लिस्टबॉक्स' के कोनों को गोल करना चाहते हैं और 'सीमा' है, क्या यह सही है ? –

+0

'ListBoxItems' –

संबंधित मुद्दे