Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to prevent a ListView from expanding the window dimension?
    text
    copied!<p>I put a ListView in the middle row of a View. The view is contained in a window that has SizeToContent set to WidthAndHeight. The ListView is initially empty, but the underlying ViewModel fills this list view in the process.</p> <p>The middle Grid.Row height is set to * to fill the available size of the window. When the ListView receives new items, it will at some point expand the window size instead of displaying the ScrollViewer in the ListView. How can I prevent this behavior to have SizeToContent set to WidthAndHeight, the Grid.Row height to * but not have the ListView expand the window dimensions?</p> <p>Here's the code for the window (the Workspace property will contain the ViewModel):</p> <pre><code>&lt;Window x:Class="Views.ContainerWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="{Binding Title}" SizeToContent="WidthAndHeight"&gt; &lt;ContentControl Content="{Binding Workspace}"/&gt; &lt;/Window&gt; </code></pre> <p>The View for the provided ViewModel looks like this:</p> <pre><code>&lt;UserControl x:Class="Views.SomeView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" MinHeight="450"&gt; &lt;Grid&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto"/&gt; &lt;RowDefinition Height="*"/&gt; &lt;RowDefinition Height="Auto"/&gt; &lt;/Grid.RowDefinitions&gt; &lt;TextBlock Grid.Row="0" TextWrapping="Wrap" Margin="5" Text="Some description text"/&gt; &lt;ListView Grid.Row="1" ItemsSource="{Binding ItemsList}" Margin="5"&gt; &lt;ListView.View&gt; &lt;GridView&gt; ... &lt;/GridView&gt; &lt;/ListView.View&gt; &lt;/ListView&gt; &lt;Button Grid.Row="2" HorizontalAlignment="Right" Command" Value="{Binding CloseCommand}"/&gt; &lt;/Grid&gt; &lt;/UserControl&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload