2011-10-26 39 views
0

我有一個綁定到數據的列表框,列表框中的每個項目都是我想要的圓角。我已經使用了邊框標籤,但似乎沒有任何效果。對列表框中的文本塊使用<border cornerradius =「10」/>

下面是我使用的代碼;

<ListBox Name="lstbMenu" Margin="0,190,6,6" Height="488"> 

       <ListBox.ItemTemplate> 

        <DataTemplate> 
        <Border CornerRadius="10"> 
         <StackPanel Orientation="Horizontal" Margin="10" Background="Beige" Width="488"> 
          <StackPanel Orientation="Vertical"> 
           <Image Source="Images/1_0_1_1B59_7DA_2_11A0000_0_0_0.png" VerticalAlignment="Center" Height="80" Width="80" Margin="10"/> 
          </StackPanel> 
          <TextBlock Text="{Binding Path=menuText}" VerticalAlignment="Center" Margin="10" FontSize="20" /> 
          <TextBlock Text="{Binding Path=menuPage}" Visibility="Collapsed" /> 
         </StackPanel> 
        </Border> 
       </DataTemplate> 

       </ListBox.ItemTemplate> 

     </ListBox> 

有沒有人有任何想法?

感謝

+0

嘗試設置了' Border「的BorderBrush和BorderThickness屬性 – Praetorian

回答

3

默認情況下,一個Border具有透明背景和0。你需要設置BorderBackgroundBorderBrushBorderThickness性質邊框厚度。

0

這與邊框的厚度代碼波紋管設定爲4和刷設置爲白色,通過設置背景屬性,你可以選擇一種顏色或添加圖像,以及:

<ListBox Name="lstbMenu" Margin="0,190,6,6" Height="488"> 

       <ListBox.ItemTemplate> 

        <DataTemplate> 
        <Border BorderThickness="4" BorderBrush="White" CornerRadius="10"> 
         <StackPanel Orientation="Horizontal" Margin="10" Background="Beige" Width="488"> 
          <StackPanel Orientation="Vertical"> 
           <Image Source="Images/1_0_1_1B59_7DA_2_11A0000_0_0_0.png" VerticalAlignment="Center" Height="80" Width="80" Margin="10"/> 
          </StackPanel> 
          <TextBlock Text="{Binding Path=menuText}" VerticalAlignment="Center" Margin="10" FontSize="20" /> 
          <TextBlock Text="{Binding Path=menuPage}" Visibility="Collapsed" /> 
         </StackPanel> 
        </Border> 
       </DataTemplate> 

       </ListBox.ItemTemplate> 

     </ListBox>