WPF StackPanel添加项目和其他项目保持相同的位置

时间:2013-12-21 16:28:52

标签: c# wpf stackpanel

我需要为stackpanel制作一个标题栏。我需要添加它并使stackpanel的其他内容保持在同一个地方。所以我应该将stackpanel向下移动一点,使标题栏看起来就像刚出现在它上面一样。然而,这不适用于旋转。

这是我尝试过的代码似乎与旋转无关:

Panel.MouseEnter += new MouseEventHandler(delegate(object o, MouseEventArgs e)
{
   Point p = new Point(0, -15);
   Border.RenderTransform.Transform(p);
   Canvas.SetTop(Border, WindowManager.NaNToZero(Canvas.GetTop(Border)) + p.Y);
   Canvas.SetLeft(Border, WindowManager.NaNToZero(Canvas.GetLeft(Border)) + p.X);
   Panel.Children.Insert(0, TitleBorder);
});
Panel.MouseLeave += new MouseEventHandler(delegate(object o, MouseEventArgs e)
{
   Point p = new Point(0, 15);
   Border.RenderTransform.Transform(p);
   Canvas.SetTop(Border, WindowManager.NaNToZero(Canvas.GetTop(Border)) + p.Y);
   Canvas.SetLeft(Border, WindowManager.NaNToZero(Canvas.GetLeft(Border)) + p.X);
   Panel.Children.Remove(TitleBorder);
});

我真的很感激这个解决方案。提前谢谢!

0 个答案:

没有答案