2011-08-24 9 views
7

için CornerRadius ile Sınır özelliğini özelleştirmek:= 5..can kimse bana şu Xaml kodda mevcut datatemplate kodu değiştirmeden bunu başarmak için yardımcı Ben CornerRadius sınırının aşağıdaki liste kutusu ekran özelliği özelleştirmek istediğiniz 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> 

cevap

10

başka CornerRadius değere sahip ListBoxItems içinde Border istiyorsanız, şunlardan birini yapabilirsiniz Border tanımlanan veya ItemContainerStyle Kaynakları örtülü olarak ayarlanır yeniden şablon ListBoxItem

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

Düzenleme: ListBox için CornerRadius ayarlamak istiyorsanız, aynı şeyi yapabilirsiniz ama Resources yerine

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

evet, her listitem ... olduğunca liste içinde bir sınır olabilir Listenin kendisi için uygulanacak köşe köşesi ile sınır özelliğine ihtiyacım var .... umarım sorularımdan anlaşılır .. –

+0

Bu yüzden "ListBox" un köşelerini yuvarlamak ve bir "Border" var, bu doğru mu? ? –

+0

"ListBoxItems" –

İlgili konular