当前设置
我有一个代表安装程序文件和有关文件的一些属性的自定义类,应符合以下接口绑定对象列表定制的ItemTemplate到的ItemsControl在MVVM
public interface IInstallerObject
{
string FileName { get; set; }
string FileExtension { get; set; }
string Path { get; set; }
int Build { get; set; }
ProductType ProductType { get; set; }
Architecture ArchType { get; set; }
bool Configurable { get; set; }
int AverageInstallTime { get; set; }
bool IsSelected { get; set; }
}
我ViewModel
有一个名为AvailableInstallerObjects
的ReadOnlyObservableCollection<IInstallerObject>
属性。
我的View
有一个GroupBox
包含ItemsControl
它结合上述性质。
<GroupBox Header="Products">
<ItemsControl ItemsSource="{Binding Path=AvailableInstallerObjects}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<CheckBox IsChecked="{Binding Path=IsSelected}"
VerticalAlignment="Center" Margin="5"/>
<TextBlock Text="{Binding Path=FileName}" Margin="5" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</GroupBox>
的结合工作正常,但它不是用户友好的。显示100多个项目。
需要帮助这里
我希望能够使用的IInstallerObject
我的珍藏,但有View
具有以下ItemTemplate
结构呈现出来。
<GroupBox Header="Products">
<ItemsControl ItemsSource="{Binding Path=AvailableInstallerObjects}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<CheckBox IsChecked="{Binding Path=IsSelected}"
VerticalAlignment="Center" Margin="5"/>
<TextBlock Text="{Binding Path=ProductType}" Margin="5" />
<ComboBox ItemsSource="{Binding Path=Build}" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</GroupBox>
基本上,我希望能够以组由ProductType
属性,显示可用产品的列表,以表示对IInstallerObject
S中ProductType
的可用Build
属性值ComboBox
。
我可以在ViewModel
中使用LINQ
来提取分组,但我不知道如何绑定到我已经提取的分组。
我的研究也发现了使用CollectionViewSource
的可能性,但我不确定如何将其应用于我当前的设置。
我很感谢你的帮助。我愿意学习,所以如果我忽略了一些明显的情况,请直接告诉我这些信息,我很乐意教育自己。