WPF ListView grows wider in response to column resizing but not shrinking

In the next .NET 3.5 XAML, if you drag the column width of the Day column wider, the ListView grows great to take this into account. However, if you then drag the column width, the table will remain the same.

The same problem exists vertically. If some of your columns have word wraps, the table will be higher to handle this, but then not shrink.

It's really dumb here. If you delete the ListView.ItemsSource section, then the ListView works as you wish! Why will this affect this?

Any ideas?

<Window x:Class="TestWpfTables.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System.Collections;assembly=mscorlib" xmlns:p="clr-namespace:System;assembly=mscorlib" Title="Window1" Height="300" Width="300"> <Grid> <ListView HorizontalAlignment="Left"> <ListView.View> <GridView> <GridViewColumn DisplayMemberBinding="{Binding Path=Day}" Header="Day" /> </GridView> </ListView.View> <ListView.ItemsSource> <s:ArrayList> <p:DateTime>1990/1/1 12:22:02</p:DateTime> <p:DateTime>1990/1/2 13:2:01</p:DateTime> <p:DateTime>1990/1/5 2:1:6</p:DateTime> </s:ArrayList> </ListView.ItemsSource> </ListView> </Grid> </Window> 
+3
source share
1 answer

In general, all WPF controls are “only for growth”, which means that we are doing the initial layout, and then the control will only resize when the content changes. The reason we did not change the default size is because it will require an expensive measure and arrange a pass, which will negatively affect performance

ref: codeplex thread

+3
source

Source: https://habr.com/ru/post/1479427/


All Articles