How to set margin for inner controls of WrapPanel
- by Andrey Tagaew
Hi Guys!
I'm new in WPF and have a question.
Here is an example that I'm using:
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<StackPanel>
<WrapPanel Orientation="Horizontal" >
<Button Content="test1" Margin="10,0" Padding="10,10" />
<Button Content="test2" Margin="10,0" Padding="10,10" />
<Button Content="test3" Margin="10,0" Padding="10,10" />
<Button Content="test4" Margin="10,0" Padding="10,10" />
<Button Content="test5" Margin="10,0" Padding="10,10" />
</WrapPanel>
</StackPanel>
As you can see, my wrap panel has several buttons.
Each button has the same margin and padding.
The question is, is there a way of setting margin and padding for wrap panel, so each element inside the wrap panel may use it values?
This make the code shorter and let me specify Margin and Padding only one time instead of setting it for each control in the panel.
Thank you!