可浮动窗口在Silverlight中调整网格大小

时间:2010-03-12 22:42:43

标签: silverlight layout dialog resize

我正在尝试在我的Silverlight应用程序中使用Tim Heuer's FloatableWindow control作为非模态选项窗口。但是,我遇到了FloatableWindow在打开时调整其父网格的问题。例如,在我打开窗口之前,应用程序看起来像这样:

Screenshot of application before FloatableWindow is open http://www.freeimagehosting.net/uploads/a71ab86e4b.png

但是在打开窗口后,网格的第一行会展开:

Screenshot of application after FloatableWindow is open http://www.freeimagehosting.net/uploads/94d97c22ee.png

我目前正在将FloatableWindow.ParentLayoutRoot设置为MainPage.xaml中的LayoutRoot网格。这是正确的做法吗?如何在FloatableWindow打开时阻止网格调整大小?

1 个答案:

答案 0 :(得分:2)

我也碰到了这个。如果您的网格是基于表格的,可浮动窗口会有点蹩脚:

<Grid x:Name="LayoutRoot">
  <Grid.RowDefinitions>
  bla bla...
  </Grid.RowDefinitions>
<Grid.ColumnDefinitions>
  bla bla...
</Grid.ColumnDefinitions>

  more of your code bla bla...
</Grid>

修复非常简单,只需为您的表添加一个虚拟网格 基于布局,只需像以前一样使用'LayoutRoot'。

<Grid x:Name="LayoutRoot">
  <Grid x:Name="DummyGrid">
    <Grid.RowDefinitions>
     bla bla...
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
     bla bla...
    </Grid.ColumnDefinitions>

    more of your code bla bla...
 </Grid>
</Grid>