2012-05-21 6 views
1

데이터베이스에서 값을 가져 와서 동적으로 만드는 확인란이 들어있는 목록 상자에 여러 개의 열이 있어야합니다.여러 열이있는 목록 상자

<StackPanel Width="250" Height="80"> 
<ListBox Name="listBoxZone" ItemsSource="{Binding TheList}" Height="115" Background="Azure"> 
<ListBox.ItemTemplate> 
    <DataTemplate> 
     <CheckBox Name="CheckBoxZone" Content="{Binding TheText}" Tag="{Binding TheValue}" Checked="CheckBoxZone_Checked" Margin="0,5,0,0"/> 
    </DataTemplate> 
    </ListBox.ItemTemplate> 
</ListBox> 

그러나 여기에서 체크 박스는 좌우 후 1 온다 ... 내가 5 확인란 후 열을 변경하려면 ... 내가 여기에 랩 패널을 사용하지만, 모든 모든 확인란을두고 : 코드는 다음과 같다 체크 박스를 수직으로 정렬합니다.

이제 어떻게해야합니까?

+0

문제점을 이해하지 못합니다. 정확히 무엇을 달성하고 싶습니까? 무슨 뜻 "나는 5 개의 확인란 후 열을 변경하고 싶다" – csteinmueller

+0

@csteinmueller .. 예 –

답변

1

이 작업을 시도해야합니다 : 항목 수가 5에 도달하는 대신 컨트롤의 폭 경계에 도달하면

<ListBox Name="listBoxZone" ItemsSource="{Binding TheList}" Height="115" Background="Azure"> 
    <ListBox.ItemsPanel> 
     <ItemsPanelTemplate> 
      <WrapPanel Width="{Binding (FrameworkElement.ActualWidth), RelativeSource={RelativeSource AncestorType=ScrollContentPresenter}}" 
         ItemWidth="{Binding (ListBox.View).ItemWidth, RelativeSource={RelativeSource AncestorType=ListBox}}" 
         MinWidth="{Binding ItemWidth, RelativeSource={RelativeSource Self}}" 
         ItemHeight="{Binding (ListBox.View).ItemHeight, RelativeSource={RelativeSource AncestorType=ListBox}}" /> 
     </ItemsPanelTemplate> 
    </ListBox.ItemsPanel> 
    <ListBox.ItemTemplate> 
     <DataTemplate> 
      <CheckBox Name="CheckBoxZone" Content="{Binding TheText}" Tag="{Binding TheValue}" Checked="CheckBoxZone_Checked" Margin="0,5,0,0"/> 
     </DataTemplate> 
    </ListBox.ItemTemplate> 
</ListBox> 

이 코드는 포장한다이 귀하의 요구 사항을 충족하지 않는 경우 당신이 대신 목록 상자의 그리드를 사용하는 것이 좋습니다 것입니다.

+0

고마워 .... –