2011-03-22 3 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

関連する問題