I have a ToolBar WPF control which has a Stackpanel docked to right. I use this toolbar control in 3 other WPF controls by adding in the XAML. When I verif开发者_如何学Cy in the XAML the Stackpanel location is same for all 3 controls. But when I run my application, for one of the 3 controls, the StackPanel in the ToolBar control shifts to left.
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal" HorizontalAlignment="Right" Name="stackButtons" >
Any idea? Appreciate your help..
I'll try three guesses.
1) You have some explicit code which changes the DockPanel.Dock property. (Highly unlikely, I'll admit)
2) The stack panel isn't actually shifting to the left. The enclosing DockPanel is actually shifting to the left, and it's still the right most control in a left most dock panel.
3) The window holding the dock panel has some additional default styles (styles which have a TargetType but not keys), and these styles are screwing things up somehow. This is unlikely, as you are setting the HorizontalAlignment as an explicit property, and explicit properties override style properties. But styles can continually surprise.
Anyway, these stabs-in-the-dark might give you ideas as to where to look.
精彩评论