C # UWP Windows 10

There is this type of ContentDialog:

<ContentDialog.Resources> <DataTemplate x:Name="MerchantListViewTemplate" x:DataType="data:Merchant"> <StackPanel VerticalAlignment="Top" Margin="20,3"> <TextBlock Grid.Row="0" Grid.Column="0" Text="{x:Bind Title}" Foreground="Black" FontSize="14" Margin="10,0,0,0" TextWrapping="NoWrap"/> </StackPanel> </DataTemplate> </ContentDialog.Resources> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <TextBox Grid.Row="0" Grid.Column="0" HorizontalAlignment="Stretch" TextChanged="TextBox_TextChanged"/> <Button Grid.Row="0" Grid.Column="1" Margin="0,0,0,0" HorizontalAlignment="Right" Background="Transparent" Visibility="{Binding settingsVisibility}"> <Button.Content> <FontIcon Glyph="&#xE109;" Tag="Addnew" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" FontFamily="Segoe MDL2 Assets" FontSize="16"/> </Button.Content> </Button> <Button Grid.Row="0" Grid.Column="2" HorizontalAlignment="Right" Background="Transparent" Visibility="{Binding settingsVisibility}"> <Button.Content> <FontIcon Glyph="&#xE10A;" Tag="Close" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" FontFamily="Segoe MDL2 Assets" FontSize="16"/> </Button.Content> </Button> <Grid Grid.Row="1" Grid.ColumnSpan="3"> <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> 

By itself, ListView does not want to scroll. How to do what you want ??

    1 answer 1

    Try setting a fixed height for the ListView.

    • It works this way, but I need a ListView for the whole dialog. - SYL
    • @SYL, your ListView is in a clearly not needed Grid. rearrange the Grid.Row and Grid.ColumnSpan to the ListView and delete the parent Grid. Then remove the fixed height from ListView, and everything should be as you need - Artem Flotsky