我有以下列表:
这些是带有扩展器作为 ListViewItems 的 ListView。ListView 本身位于 ScrollViewer 中以进行正确的滚动行为。我的问题是 MouseWheel 不适用于此列表。
这是 XAML:
<Window x:Class="ResourceListExpanderStyle.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converter="clr-namespace:ResourceListExpanderStyle.Converter"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<converter:DeviceTypeGroupToDeviceListConverter x:Key="DeviceTypeGroupToDeviceListConverter" />
<converter:IntegerToBrushConverter x:Key="IntegerToBrushConverter" />
</Window.Resources>
<DockPanel>
<ScrollViewer x:Name="ScrollViewer">
<ListView x:Name="OuterListView" ItemsSource="{Binding DeviceTypeGroupListByStation}" HorizontalContentAlignment="Stretch">
<ListView.ItemTemplate>
<DataTemplate>
<Expander Header="{Binding Path=NAME}" Background="{Binding Path=BACKCOLOR, Converter={StaticResource IntegerToBrushConverter}}">
<ListView x:Name="InnerListView" ItemsSource="{Binding Converter={StaticResource DeviceTypeGroupToDeviceListConverter}}" HorizontalContentAlignment="Stretch">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=NAME}" Background="{Binding Path=BACKCOLOR, Converter={StaticResource IntegerToBrushConverter}}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Expander>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ScrollViewer>
</DockPanel>
任何想法?