Can any one please tell me how to create stackPanels in .cs coding? I need to create multiple stack panels by coding. Can any one pls help regarding this?
Asked
Active
Viewed 155 times
1 Answers
1
You need to have a container in your main page to your stackpanels.
Xaml
<Grid x:Name="LayoutRoot" Background="White" Width="500" Height="500">
</Grid>
Code
StackPanel sp = new StackPanel();
sp.Orientation = Orientation.Horizontal;
//add something in your stack panel
LayoutRoot.Children.Add(sp);

Cybermaxs
- 24,378
- 8
- 83
- 112
-
Hi, Thanks for your response. Actually i am creating creating dynamic user controls. I need to add two sets of radio button. Each set has two radio buttons. while adding all the four buttons under single stack panel i can able to select any 1 among four radio buttons. But i need to select two radio buttons. So i need to create two stack panels. Could you pls tell me how to create two stack panel in code? And also i need to create stack panel as per user's input.. Could you pls share your idea? – Kannan Thangamuthu Jan 23 '13 at 12:53
-
1so what is your question ? – Cybermaxs Jan 23 '13 at 12:54
-
Hi, I need to add stack panels dynamically in xaml.cs file? If we need to create single stack panel then we can do it by StackPanel st = new StackPanel() But if we want to create for 10 times or n times then how can we do that? Could you pls suggest anything ? – Kannan Thangamuthu Jan 23 '13 at 13:00
-
1You should add more detail and some of your code to clarify your original question. – John Bowen Jan 23 '13 at 13:52
-
ok if you create a two sets of buttons in a code you can select any one from that four buttons. can you agree with this?\ – Kannan Thangamuthu Jan 23 '13 at 14:36