【发布时间】:2010-08-22 08:36:26
【问题描述】:
我有一个 WPF 业务线应用程序。其中大部分托管在选项卡中的用户控件中。 我在找出如何布局它以使其适合任何分辨率(必要时滚动)时遇到问题。 这是代码中描述的问题,因为我真的不知道如何将其放入文本中,如果不清楚,请告诉我,我会尝试绘制一些东西。
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition> <!--What i actually want to say here isn't "take all remaining space" but "take all remaining space without scrolling,
and then scroll based on everything as if this was auto and no longer *-->
<ColumnDefinition Width="Auto"></ColumnDefinition><!--But what happens for now is that since this is auto , it will not scroll at all untill the * column has fully scrolled-->
</Grid.ColumnDefinitions>
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label></Label>
<TextBox></TextBox>
</StackPanel>
</StackPanel>
<StackPanel Grid.Column="1">
<StackPanel Orientation="Horizontal">
<button> <!-- I want the button's container to be in an auto column , don't
want it to take size away from the fields unless needed but don't
want it to stay visible at the expense of the fields either -->
</StackPanel>
</StackPanel>
<TelerikGrid:RadGridView Grid.Row="1" Grid.ColumnSpan="2">
<TelerikGrid:RadGridView.Columns>
<TelerikGrid:GridViewDataColumn Width="*"/> <!-- This makes my grid take a bajillon kilometers because it itself is in a Grid's column of * size itself in a scrollviewer -->
</TelerikGrid:RadGridView.Columns>
</TelerikGrid:RadGridView>
</Grid>
【问题讨论】:
-
行和列从 0 开始编号,而不是 1。你错了。
-
对不起是一个错字,因为我想做一个更简单的例子,并在可选的地方添加了一些数据(因为如果不添加,它默认为 0/0)。将解决它,但不是导致问题的原因。
-
是您在 ScrollViewer 中的第一个 StackPanel 吗?否则我认为它根本不会滚动。