Silverlight 网格调整大小问题
我正在开发一个 Silverlight Web 应用程序,现在正在开发一个分为三列的子窗口。左边是不会一直显示的消息,还有两个(中间和右边)是一直显示的消息。
我的问题是:如果左列不需要显示任何数据,如何使右列和中列用尽所有空间?因此,例如,如果我的子窗口宽度为 100,则三个窗口中的每一个都应为 33.333,或者如果不需要显示左侧窗口,则其他两个窗口均为 50。有没有什么方法可以不弄乱后面的代码?
编辑:子窗口看起来像这样,
<controls:ChildWindow ...
<Grid x:Name="LayoutRoot" Margin="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Name="msgGrid" Grid.Column = 0/>
<Grid Grid.Column = 1/>
<Grid Grid.Column = 2/>
</controls:ChildWindow>
我将一个布尔值(showMessageToUser
)传递到子窗口的构造函数中,并根据该值确定要做什么
I am developing a Silverlight web app and am working now on a child window which is separated in three columns. The left is for messages which will not be displayed always, and two (middle and right) which will be displayed always.
My question is: How can I make the right and middle column use up all the space if the left column doesnt need to show any data? So if for example my child window is 100 in width every of the three should be 33.333 or if the left one doesn't need to be displayed then the other two are both 50. Is there any way without messing in code behind?
Edit: The child window looks like this
<controls:ChildWindow ...
<Grid x:Name="LayoutRoot" Margin="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Name="msgGrid" Grid.Column = 0/>
<Grid Grid.Column = 1/>
<Grid Grid.Column = 2/>
</controls:ChildWindow>
I am passing a bool value (showMessageToUser
) into the constructor of the child window and based on that it should be determined what to do
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将第一列设置为“自动”大小,将第二两列的宽度设置为 1*(或仅 *)。
第一列将折叠为其内容(大概您将显示/隐藏),后两列将各占 50%,因为 * 大小只是一个比率。
在第一列中放置一个名称容器(另一个网格?)并控制其可见标志。其他两列会自行处理。
控制msGrid1的可见性以获得您想要的效果。如果您还希望用户控制第 0 列的宽度(例如使用 GridSplitter),您将需要代码隐藏,因为这两个功能不能一起工作。
Make the first column "Auto" size and the second two columns 1* (or just *) in width.
The first column will collapse to its contents (which presumably you will show/hide) and the second two will take up 50% each as the * sizing is just a ratio.
Put a name container (another grid?) in the first column and control its visible flag. The other 2 columns will take care of themselves.
Control the visibility of msGrid1 to get the effect you wanted. If you also want user control of the the width if column 0 (e.g. with a GridSplitter) you will need code-behind as the two features do not work together.