[英]WPF ListView Column width
I used list view with a single column, I would like this column with the same size list view with.我使用单列的列表视图,我希望此列具有相同大小的列表视图。 I mean Just one column fill the all with of the list view.
我的意思是只有一列填充列表视图的所有内容。
I tried this but didn't work...我试过这个,但没有用...
<ListView Grid.Row="1" Grid.Column="1" x:Name="LvErrorList">
<ListView.View>
<GridView>
<GridViewColumn Width="{Binding ActualWidth, ElementName=LvErrorList}" Header="Status" DisplayMemberBinding="{Binding ErrorMessage}" />
</GridView>
</ListView.View>
</ListView>
I tried我试过
<GridViewColumn Width="Auto" Header="Status" DisplayMemberBinding="{Binding ErrorMessage}" />
But some text are longer than the with of the ListView.但是有些文本比 ListView 的 with 更长。 Becaues i don't know the user screen size i can't set max-width property.
因为我不知道用户屏幕尺寸我不能设置 max-width 属性。
Does anyone know how to fix this please?有谁知道如何解决这个问题?
You can try this way instead.你可以试试这种方式。
<ListView Grid.Row="1" Grid.Column="1" x:Name="LvErrorList">
<ListView.View>
<GridView>
<GridViewColumn Header="Status" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding ErrorMessage}" Width="{Binding ElementName=LvErrorList,Path=ActualWidth}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.