这可能是一个有点愚蠢的问题,但我不确定还能尝试什么,所以想寻求一些帮助。我的问题是 Silverlight 中的锚定控件。
我有一个位于控件中的网格(C1FlexGrid)。该控件在页面中使用,我只是希望网格大小由浏览器窗口的大小确定。我想为它设置一个最小尺寸,但允许它在用户展开浏览器窗口时垂直和水平扩展。在 WinForms(这是我习惯的)中,这很容易。
然而,在 Silverlight 中,这让我很头疼。是否有可能让它按照我想要的方式行事?
我已将控件宽度和高度设置为自动,并指定了一些设计宽度/高度。然后将用户控件放置到页面上,并将控件和页面宽度/高度都设置为自动。
当网格加载它的数据时,几百行,它会根据事实自动调整网格的大小,因为它有 200 行,即变得很长。
编辑
这是来自一个简单示例的一些 XAML:
<navigation:Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml" x:Class="Optimize.Client.Presentation.AboutView"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
Title="About"
x:Name="AboutPage"
Style="{StaticResource PageStyle}">
<Grid x:Name="LayoutRoot" Background="White" MinWidth="300" MinHeight="300">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<c1:C1FlexGrid Margin="10" BorderBrush="Red" BorderThickness="1" Width="Auto" Height="Auto" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
<c1:C1FlexGrid.Columns>
<c1:Column Header="User Group" Width="*" />
</c1:C1FlexGrid.Columns>
</c1:C1FlexGrid>
</Grid>
</navigation:Page>
我想要的只是页面上的网格。该页面的最小尺寸为 300x300。当浏览器窗口展开时,我希望页面随之展开,网格也随之展开,这样网格的所有边框都是从上/下/左/右开始的 10。我尝试将 * 指定为布局网格的宽度/高度,但它仍然无法正常工作。
谢谢