0

C# UWP 视窗 10

这是我的内容对话框的 XAML 代码:

 <Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="Auto"/>
    </Grid.ColumnDefinitions>

    .....

    <Grid Grid.Row="1" Grid.ColumnSpan="2">
        <ListView x:Name="MerchantList"                
            ItemTemplate="{StaticResource MerchantListViewTemplate}"
            SelectionMode="Single"
            SelectedValue="{Binding currItemId, Mode=TwoWay}"
            SelectedValuePath="Id"
            ShowsScrollingPlaceholders="True">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                    <Setter Property="Margin" Value="0"/>
                    <Setter Property="Padding" Value="0"/>
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>
    </Grid>
</Grid>

我需要向用户显示一些项目的列表,但 ListView 不滚动。如何解决?

4

2 回答 2

2

尝试设置一些“非自动”的列和行大小(像素或星号,没关系)。我真的无法在文档中找到这种行为的任何原因,但在我的情况下它有所帮助。

于 2016-04-09T20:11:30.160 回答
0
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="Auto"/>
    </Grid.ColumnDefinitions>



    <Grid Grid.Row="1" Grid.ColumnSpan="2">
        <ScrollViewer VerticalScrollMode="Enabled" HorizontalScrollMode="Enabled" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
        <ListView x:Name="MerchantList"                
        ItemTemplate="{StaticResource MerchantListViewTemplate}"
        SelectionMode="Single"
        SelectedValue="{Binding currItemId, Mode=TwoWay}"
        SelectedValuePath="Id"
        ShowsScrollingPlaceholders="True">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                    <Setter Property="Margin" Value="0"/>
                    <Setter Property="Padding" Value="0"/>
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>
        </ScrollViewer>
    </Grid>
</Grid>

尝试这个 ....

于 2016-04-14T13:57:02.847 回答