Yog*_*esh 39 wpf listview gridview gridviewcolumn wpfdatagrid
我使用的是ListView控件而不是DataGrid我的WPF应用程序.我想给*我的宽度ListView.GridViewColumn,但每当我提供*宽度时ListView.GridViewColumn,它给我一个编译时错误.请建议我如何提供*宽度ListView.GridViewColumn,以便ListView.GridViewColumn在我最大化屏幕时自动填充额外空间.
对此的任何帮助将非常感谢.谢谢
Bil*_*hmi 70
请尝试该解决方案:
<ListView>
<ListView.View>
<GridView>
<GridViewColumn Header="column1" x:Name="col1"/>
<!--Column that shall resize: Width is set to the Actual Width of the helper field defined below-->
<GridViewColumn Header="column2"
Width="{Binding ElementName=helperField, Path=ActualWidth}"/>
</GridView>
</ListView.View>
Test Text
</ListView>
<!--This is the hidden helper Grid which does the resizing -->
<Grid Visibility="Hidden">
<Grid.ColumnDefinitions>
<!--Width is bound to width of the first GridViewColumn -->
<ColumnDefinition Width="{Binding ElementName=col1, Path=ActualWidth}"/>
<!--Width is set to "Fill"-->
<ColumnDefinition Width="*"/>
<!--Correction Width-->
<ColumnDefinition Width="10"/>
</Grid.ColumnDefinitions>
<!--This is the hidden helper Field which is used to bind to, using the "Fill" column of the helper grid-->
<Grid Grid.Column="1" x:Name="helperField"/>
</Grid>
Run Code Online (Sandbox Code Playgroud)
您还可以在以下链接中找到其他解决方案:
http://social.msdn.microsoft.com/forums/en-US/wpf/thread/3ee5696c-4f26-4e30-8891-0e2f95d69623/
| 归档时间: |
|
| 查看次数: |
58657 次 |
| 最近记录: |