I am trying to get a horizontal StackPanel with some text, and then the button got stuck all the way to the right side. I tried this:
<StackPanel Orientation="Horizontal"> <TextBlock VerticalAlignment="Center" FontSize="14" Margin="5,0,0,0">Ahoy!</TextBlock> <Button HorizontalAlignment="Right" Width="25" Height="25" Style="{StaticResource buttonGlassOrb}" Background="Red" /> </StackPanel>
This does not work. Obviously, adding a field to a TextBlock will work as follows:
<StackPanel Orientation="Horizontal"> <TextBlock VerticalAlignment="Center" FontSize="14" Margin="5,0,120,0">Ahoy!</TextBlock> <Button HorizontalAlignment="Right" Width="25" Height="25" Style="{StaticResource buttonGlassOrb}" Background="Red" /> </StackPanel>
But this is bad for various reasons. Are there any more natural ways to do this?
wpf silverlight
Adam rackis
source share