2011-03-22 5 views
0

XAML에서 왼쪽의 목록 또는 격자에 어떻게 콤보 상자가 있고 오른쪽에 여러 개의 확인란이 직선으로 나타 납니까?WPF combox 및 다중 확인란

내가 데이터 구조를 가지고 있다고 가정 해 보겠습니다.

sudo: 

// for combo 
class Option 
{ 
    int key {get;set;} 
    string value{get;set;} 
} 

// for checkboxes 
class Selection 
{ 
    int key {get;set;} 
    string value{get;set;} 
    bool isSelected {get;set;} 
} 


class Item 
{ 
    Item 
    { 
    selections = new List<Selection>(); 
    Options = new List<Option>(); 
    } 
    List<Selection> selections {get;set;} 
    List<Option> Options{get;set;}  
} 

이제 항목 출처가됩니다.

List<Item> x = new List<Item>(); 

Item i = new Item(); 
i.Selections.add(blah); 25 selections 
i.Options.add(blah); 3 checkboxes 
x.add(i) 50 combination's. 

control.itemsource = x; 

XAML의 외관은 어떻습니까? 나는 그것을 얻지 못해서 붙어있다.

감사합니다 ...

답변

3
<ListBox ItemsSource="{Binding Items}" > 
    <ListBox.ItemTemplate> 
     <DataTemplate> 

      <!-- This is your combobox --> 
      <DockPanel HorizontalAlignment="Stretch" LastChildFill="False"> 
       <ComboBox ItemsSource="{Binding Options}" DockPanel.Dock="Left"> 
        <ComboBox.ItemTemplate> 
         <DataTemplate> 
          <TextBlock Text="{Binding value}" /> 
         </DataTemplate> 
        </ComboBox.ItemTemplate> 
       </ComboBox> 

       <!-- This is your line of checkboxes --> 
       <ListBox ItemsSource="{Binding Selections}" DockPanel.Dock="Right"> 
        <ListBox.ItemsPanel> 
         <ItemsPanelTemplate> 
          <StackPanel Orientation="Horizontal"/> 
         </ItemsPanelTemplate> 
        </ListBox.ItemsPanel> 
        <ListBox.ItemTemplate> 
         <DataTemplate> 
          <CheckBox IsChecked="{Binding isSelected}" /> 
         </DataTemplate> 
        </ListBox.ItemTemplate> 
       </ListBox> 
      </DockPanel> 
     </DataTemplate> 
    </ListBox.ItemTemplate> 
</ListBox> 
+0

안녕하세요 몬티 대단히 감사합니다. 아직 시도하지는 않았지만 좋은 출발점이되었습니다! 매우 감사. – nitefrog