Stretch empty WPF ListView to take the remaining space

This has nothing to do with the ListView. It is the StackPanel’s “fault”. In a StackPanel the child items always consume only the space they need (in the direction of the orientation of the StackPanel). That’s how the StackPanel is designed. Use a DockPanel instead, there you can make the last item fill up all the space that is left over using LastChildFill="true" (true is default, so no need to explicity specify it).

<DockPanel Background="Green">
    <Button DockPanel.Dock="Top">Text</Button>
    <ListView DockPanel.Dock="Top">
        <ListView.View>
            <GridView>
                <GridViewColumn/>
            </GridView>
        </ListView.View>
    </ListView>     
</DockPanel>

Leave a Comment