当前设置
我有一个代表安装程序文件的自定义类和关于该文件的一些属性,符合以下接口
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有一个ReadOnlyObservableCollection<IInstallerObject>名为AvailableInstallerObjects.
MyView有一个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 多个项目。
在这里需要帮助
我希望能够使用我的IInstallerObjects 集合,但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属性进行分组,显示可用产品的列表,其中表示 .s的ComboBox可用Build属性值。IInstallerObjectProductType
我可以使用LINQinViewModel来提取分组,但我不知道如何绑定到我提取的内容。
我的研究还发现了使用 a 的可能性,CollectionViewSource但我不确定如何将它应用到我当前的设置中。
我提前感谢您的帮助。我愿意学习,所以如果我忽略了一些明显的东西,请引导我查看信息,我很乐意自学。