Pregunta

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>
¿Fue útil?

Solución

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>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top