2016-03-18 30 views
-1

我们正在研究一个应用程序,使用MVVM架构风格(WPF)并面临一个问题。 使用前WPF我们已与WinForms和我们使用CheckedListBox。但是现在我们无法在WPF中找到这样的控制。 我们也使用Infragistic工具包。WPF中的CheckedListBox

请提供任何形式的帮助。任何铅都将是可观的。 enter image description here

回答

2

你可以把一个列表框,并在复选框中给它一个模板 喜欢的东西:

<ListBox ItemsSource="{Binding MyItems}"> 
     <ListBox.ItemTemplate> 
      <DataTemplate> 
       <CheckBox IsChecked="{Binding IsSelected}" Content="{Binding}" /> 
      </DataTemplate> 
     </ListBox.ItemTemplate> 
    </ListBox> 

这看起来是这样的:

Checklistbox in WPF

编辑:项目必须有一个属性“IsSelected”,或者你必须将它们包装在一个SelectableItem助手类中,该助手类包含原始Item和IsSelected属性。