Reputation: 1332
I have 12 Buttons in for example one DockPanel. My question is how to inherit the Width of my DockPanel to the Buttons, so that they all have the same Width
<DockPanel Width="1200" Height="30">
<Button Width="100" Content="Januar" />
<Button Width="100" Content="Februar" />
<Button Width="100" Content="März" />
<Button Width="100" Content="April" />
<Button Width="100" Content="Mai" />
<Button Width="100" Content="Juni" />
<Button Width="100" Content="Juli" />
<Button Width="100" Content="August" />
<Button Width="100" Content="September" />
<Button Width="100" Content="Oktober" />
<Button Width="100" Content="November" />
<Button Width="100" Content="Dezember" />
</DockPanel>
When im changing the width of my Dockpanel i want to change the width of the buttons too..
I know..
Width={Binding ElementName=dockpanel1, Path=Width}
.. but i have to do take this width / 12.
Upvotes: 1
Views: 184
Reputation: 128147
Use a UniformGrid
instead of a DockPanel
:
<UniformGrid Rows="1" Width="1200" Height="30">
<Button Content="Januar" />
<Button Content="Februar" />
<Button Content="März" />
<Button Content="April" />
<Button Content="Mai" />
<Button Content="Juni" />
<Button Content="Juli" />
<Button Content="August" />
<Button Content="September" />
<Button Content="Oktober" />
<Button Content="November" />
<Button Content="Dezember" />
</UniformGrid>
Upvotes: 2