silverlight弹出子窗体不能居中
请教个问题。有个查询子窗体,继承于ChildWindow,有时候可以居中,有时不居中,拖动一下,下次再打开还有记忆窗体位置的功能。
[解决办法]
控制silverlight的childwindow,可以通过扩展类实现,例如:
public partial class ChildWindowEx : ChildWindow{ Point _pt = new Point(0,0); public ChildWindowEx() { InitializeComponent(); } public ChildWindowEx(Point pt) : this() { _pt = pt; } protected override Size ArrangeOverride(Size finalSize) { Grid grid = Utils.FindChild<grid>(this, \"ContentRoot\"); if (grid != null) { grid.Arrange(new Rect(_pt.X, _pt.Y, grid.DesiredSize.Width, grid.DesiredSize.Height)); return finalSize; } return base.ArrangeOverride(finalSize); }}