2010-05-18 2 views

답변

1

필요에 따라 여백 및 여백을 설정하려면 ItemContainerStyle을 설정하십시오. 혼합은이 retemplating 도움이 될 것입니다.

그런 다음 DataTemplate을 설정할 수도 있습니다.

0

다른 사람들보다 나보다 잘 알지도 모르지만 목록 상자의 데이터 템플릿을 재정의합니다. 각 개별 항목에 대해 텍스트 컨트롤의 크기를 명시 적으로 지정하십시오. 예를 들어

:

<ListBox Width="400" Margin="10" ItemsSource="{Binding Path=MyDataItems}"> 
    <ListBox.ItemTemplate> 
    <DataTemplate> 
     <TextBlock Text="{Binding Path=TaskName}" Height="27" /> 
    </DataTemplate> 
    </ListBox.ItemTemplate> 
</ListBox> 

그것은 확실히 조금 더 많은 작업이지만, 난 당신이 목록 상자를 위해 할 수있는 다른 많은이 확실하지 않다.

0

내가 유, 난 그냥 u는 당신의 목록 상자에 존재하는 listboxitems 사이의 공간을 감소 할 것으로 추측 데 원하는 정말 무엇인지 잘 모릅니다 좋아, 당신은 여백의 도움으로 그것을 할 수 있습니다 :

<Style x:Key="LedgerListBoxItem" TargetType="ListBoxItem"> 
     <Setter Property="Padding" Value="3"/> 
     <Setter Property="Height" Value="24"/> 
     <Setter Property="Width" Value="330"/> 
     <Setter Property="HorizontalContentAlignment" Value="Left"/> 
     <Setter Property="VerticalContentAlignment" Value="Top"/> 
     <Setter Property="Background" Value="Transparent"/> 
     <Setter Property="BorderThickness" Value="1"/> 
     <Setter Property="TabNavigation" Value="Local"/> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="ListBoxItem"> 
        <Grid Background="{TemplateBinding Background}">      
         <Grid HorizontalAlignment="Stretch" **Margin="0 4 0 4"**> 
          <Grid.ColumnDefinitions> 
           <ColumnDefinition Width="4"/> 

           <ColumnDefinition /> 
          </Grid.ColumnDefinitions> 
          <Image Grid.Column="1" Source="../Styles/Images/icon-exception.png" 
    /> 

         </Grid> 
         <Rectangle x:Name="FocusVisualElement" RadiusY="4" RadiusX="4" Stroke="#FF6DBDD1" StrokeThickness="0" Visibility="Collapsed" /> 
        </Grid> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 

더 많은 도움을 받으려면 ur 코드를 올리십시오. :)

관련 문제