Question

I have a ListView which is using a GridView to display a DataTable and when new rows are added to the DataTable the ListView grows as expected but when it reaches the bottom of the Canvas it carries on growing.

I want it to stop when it reaches the height of the Canvas, how can I configure this?

The Canvas has a dynamic height which is controlled by the DockPanel it is contained in.

<Canvas>
    <ListView Name="listResults" ItemsSource="{Binding}">
        <ListView.View>
            <GridView>
                <GridViewColumn Header="Request Time" DisplayMemberBinding="{Binding RequestTime}" />
                <GridViewColumn Header="Request Duration(ms)" DisplayMemberBinding="{Binding Duration}" />
                <GridViewColumn Header="Request Duration(ms)" DisplayMemberBinding="{Binding Duration}" />
            </GridView>                            
        </ListView.View>
    </ListView>
</Canvas>
Was it helpful?

Solution

Set the MaxHeight property on your ListView. You could hard code it, or you could bind it to the ActualHeight property of the Canvas.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top