Проблемы с прокруткой с несколькими ListView в WPF - PullRequest
0 голосов
/ 27 июня 2018

Я новичок в WPF, около 2 часов life :) и уже получил эту проблему. Я хочу сделать что-то «похожее» на Bootstrap со списком заказов и внутри каждого заказа список товаров. Я управляю этим с помощью ListView внутри другого ListView, но сейчас я не могу получить ни одного из моих свитков. Как я могу заставить мой свиток работать?

Примечание: это для использования планшета (сенсорный), я специально спрятал свиток.

enter image description here

Это мой действительный код

<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);            
    }      
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...