Alex Rivera | Logout

WPF Toolbar Items HorizontalAligment="Right"

Asked 2010-02-04T17:16:25.400
19

Is it possible to make the elements within a WPF toolbar have a HorizontalAlignment of Right?

<ToolBar Height="38" VerticalAlignment="Top" Grid.Row="1">
    <Button HorizontalAlignment="Left" Width="50" VerticalAlignment="Stretch"/>
    <Button HorizontalAlignment="Left" Width="50" VerticalAlignment="Stretch"/>
    <ComboBox Width="120" HorizontalAlignment="Right"/>
</ToolBar>

I've tried adding the elements inside into a Grid and assigning the ColumnDefinitions to Left/Right as well. I have also tried a StackPanel. No matter what I try I can't seem to get the ComboBox to be "anchored" on the right side of the Toolbar.

UPDATE:

<DockPanel LastChildFill="True">

Doesn't work, It will not fill the ToolBar element like it would a normal element.

Edit
Report

1 Answer

2

Have you tried using a DockPanel that fills the toolbar, then you can dock the ComboBox to the right.

Remember that with a dockpanel the sequence you put the items in is very important.

HTH

answered 2010-02-04T17:58:16.250

Your Answer