You can use SpicyTaco.AutoGrid - a modified version of StackPanel
:
<st:StackPanel Orientation="Horizontal" MarginBetweenChildren="10" Margin="10">
<Button Content="Info" HorizontalAlignment="Left" st:StackPanel.Fill="Fill"/>
<Button Content="Cancel"/>
<Button Content="Save"/>
</st:StackPanel>
First button will be fill.
You can install it via NuGet:
Install-Package SpicyTaco.AutoGrid
I recommend taking a look at SpicyTaco.AutoGrid. It's very useful for forms in WPF instead of DockPanel
, StackPanel
and Grid
and solve problem with stretching very easy and gracefully. Just look at readme on GitHub.
<st:AutoGrid Columns="160,*" ChildMargin="3">
<Label Content="Name:"/>
<TextBox/>
<Label Content="E-Mail:"/>
<TextBox/>
<Label Content="Comment:"/>
<TextBox/>
</st:AutoGrid>