How to set the width to 100%

I have a stack of silverlight and I want to set its width to 100%.

I am adding a dynamic stack panel (C #)

+4
source share
2 answers

Try setting the HorizontalAlignment to "Stretch" on your StackPanel and make sure that your containing element is also the width you expect.

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

Instead of 300, use the property of the parent container?

0
source

Source: https://habr.com/ru/post/1316282/


All Articles