简体   繁体   English

如何将宽度设置为100%

[英]How to set width to 100%

I have a silverlight stackpanel and i want to set its width to 100%. 我有一个silverlight stackpanel,我想将其宽度设置为100%。

i'm adding the stackpanel dynamically (C#) 我正在动态添加堆栈面板(C#)

尝试在StackPanel上将Horizo​​ntalAlignment设置为“Stretch”,并确保包含元素也是您期望的宽度。

private void CreateMyDynamicStackPanel()
{
    StackPanel MyStackPanel = new StackPanel();
    MyStackPanel.HorizontalAlignment = HorizontalAlignment.Stretch;
    MyStackPanel.Width = 300;
}

Instead of 300, use a property of the parent container? 而不是300,使用父容器的属性?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM