guys
I have StackPanel. I need place there TextBlock with TextAlignment = TextAlignment.Center[Center of stackPanel] and button at right side with small margin.
How can I achieve such layout with wpf.
How can I add button to StackPanel, that my TextBlock doesn’t move from center.
Try something like this:
Notice that the TextBox spans the entire Grid (ColumnSpan=”2″), so that it will be absolutely centered in the Grid (HorizontalAlignment=”Center”). The second column will just have a StackPanel (or Grid, or UniformGrid, or…) with the buttons.
NOTE: The known drawback of this design is that the buttons could overlap the TextBox if the TextBox is big enough and the Grid is small enough. Care will have to be taken to avoid this, and is left as an exercise for the developer. However, this drawback will occur on any implementation where the requirement is that the TextBox is dead-center of the layout.