我是WPF的初学者,大约2小时的工作时间:),并且已经遇到了这个问题。 我想做一些类似于Bootstrap的订单列表,并在每个订单中添加产品列表。 我正在使用其他ListView内的ListView进行管理,但是现在我的任何滚动条都无法使用。如何使滚动条正常工作?
注意:这是供平板电脑使用(触摸),我特意隐藏了滚动条。
这是我的实际代码
<ListView ItemsSource="{Binding HardwareList}" Name="ListHardware" Margin="12,132,12,12" Background="{x:Null}" BorderBrush="{x:Null}" ScrollViewer.VerticalScrollBarVisibility="Disabled" >
<ListView.ItemTemplate>
<DataTemplate>
<Grid Height="235">
<Grid Height="220" Width="1338" Background="#fbe8e5" VerticalAlignment="Top">
<Border BorderBrush="#dd4b39" BorderThickness="1" CornerRadius="3">
<Grid>
<Grid Height="39" Width="1338" Background="#dd4b39" VerticalAlignment="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Content="Stock Picking:" Grid.Column="0" VerticalAlignment="Center" Foreground="White" FontSize="18" FontWeight="Bold"></Label>
<Label Content="{Binding Order}" Grid.Column="1" VerticalAlignment="Center" Foreground="White" FontSize="18"></Label>
<Label Content="[Imported]" Grid.Column="2" VerticalAlignment="Center" HorizontalContentAlignment="Right" Foreground="White" FontSize="18"></Label>
</Grid>
<ListView ItemsSource="{Binding Hardwares}" Name="Hardware" Background="{x:Null}" BorderBrush="{x:Null}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" >
<ListView.ItemTemplate>
<DataTemplate>
<Grid Height="151" Width="318" Margin="12,50,0,12">
<Button Content="{Binding Name}"></Button>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<ContentPresenter />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
</ListView>
</Grid>
</Border>
</Grid>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<ContentPresenter />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
</ListView>
到目前为止,在.cs类上还是很简单的
private void LoadHardware()
{
for (int i = 0; i < 20; i++)
{
HardwareList hardwareList = new HardwareList();
hardwareList.Order = "Order/10472" + i;
hardwareList.Status = "Done-"+ i;
List<Hardware> hardwares = new List<Hardware>();
for (int j = 0; j < 10j++)
{
Hardware hardware = new Hardware();
hardware.Name = "product_00"+j;
hardware.Qty = "20";
hardwares.Add(hardware);
}
hardwareList.Hardwares = hardwares;
ListHardware.Items.Add(hardwareList);
}
}