Reputation: 2571
More or less the same question like here, but right align: HorizontalAlignment=Stretch, MaxWidth, and Left aligned at the same time?
How do I get this blue text box to grow with the size of the window, have a maximum width of 200 pixels, and be right justified?
This is what I have, but it's centered instead of right aligned. Why?
<DockPanel Background="LightSteelBlue">
<TextBox Margin="3 3 3 3" DockPanel.Dock="Right" MaxWidth="200" />
</DockPanel>
Upvotes: 2
Views: 2084
Reputation: 2571
Lets answer my own question. This works, but it's not an example of nice code. There must be a much better solution.
<Grid Background="LightSteelBlue">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="1000*" MaxWidth="200"/>
</Grid.ColumnDefinitions>
<TextBox Margin="3 3 3 3" Grid.Column="1" />
</Grid>
Upvotes: 3