【发布时间】:2009-07-13 23:52:36
【问题描述】:
在以下 .NET 3.5 XAML 中,如果将“Day”列的列宽拖得更宽,ListView 会很好地增长以解决此问题。但是,如果您随后将列宽拖得更窄,表格将保持原来的大小。
同样的问题在垂直方向也存在。如果您的某些列有自动换行,则表格会变高以处理此问题,但不会缩回。
这是真正愚蠢的部分。如果您删除 ListView.ItemsSource 部分,则 ListView 将按需要工作!为什么会影响它?
有什么想法吗?
<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>
【问题讨论】:
-
删除 ListView.ItemsSource 部分是什么意思?那么 ListView 是空的,对吧?快把我逼疯了,也不知道怎么缩小。