Silverlight: Restrict RowDetailsTemplate width to it's parent DataGrid's width
我想将RowDetailsTemplate的Width绑定到DataGrid的Width,这样行详细信息就不会被滚动条包围。
问题出在这里:
请注意,RowDetailsTemplate包含必须滚动到视图中的隐藏内容-这太糟糕了。用户必须拖动DataGrid底部最底部的滚动条,才能查看该行的其余详细信息-这非常不直观。我真的很希望行详细信息对其内容进行布局,从而无需滚动。
有什么建议吗?
谢谢,
查尔斯
我确实找到了WPF中类似问题的解决方案,您可以在这里找到它:DataGrid RowDetails宽度问题
我不知道它是否可以在Silverlight中工作,但是请尝试一下。
The answers here felt like a workaround so I did some research and did
find the solution on the Telerik forums, since we use their
RadGridView. Turned out the solution worked for DataGrid as well.The key is to set the ScrollViewer.HorizontalScrollBarVisibility
property to Disabled, see example below.
1
2
3
4
5
6
7
8
9 <DataGrid ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<Border>
<TextBlock Foreground="White" Text="{Binding RowDetails}"
TextWrapping="Wrap"/>
</Border>
</DataTemplate>
</DataGrid.RowDetailsTemplate> </DataGrid>
将我的
1 | <data:DataGrid AreRowDetailsFrozen="True" /> |