Align items in a stack panel?
问题 I was wondering if I can have 2 controls in a horizontal-oriented StackPanel so that the right item should be docked to the right side of the StackPanel. I tried the following but it didn't work: <StackPanel Orientation="Horizontal"> <TextBlock>Left</TextBlock> <Button Width="30" HorizontalAlignment="Right">Right<Button> </StackPanel> In the snippet above I want the Button to be docked to the right side of the StackPanel. Note: I need it to be done with StackPanel, not Grid etc. 回答1: You can