你好,
这个不是bug,我们可以根据childwindow的布局改变,重设居中
建议重写childwindow的onopen事件
protected override void OnOpened()
{
this.LayoutUpdated += new EventHandler(OnChildWindowLayoutUpdated);
base.OnOpened();
}
//in the ctor:
this.Closed += new EventHandler(OnChildWindowClosed);
void OnChildWindowClosed(object sender, EventArgs e)
{
this.LayoutUpdated -= OnChildWindowLayoutUpdated;
}
void OnChildWindowLayoutUpdated(object sender, EventArgs e)
{
var root = VisualTreeHelper.GetChild(this, 0) as FrameworkElement;
if (root != null)
{
var contentRoot = root.FindName("ContentRoot") as FrameworkElement;
if (contentRoot != null)
{
var group = contentRoot.RenderTransform as TransformGroup;
if (group != null)
if (group.Children.Count == 6)
{
var tf1 = group.Children[3] as TranslateTransform;
var tf2 = group.Children[5] as TranslateTransform;
if (tf1 != null)
{
tf1.X = 0;
tf1.Y = 0;
}
if (tf2 != null)
{
tf2.X = 0;
tf2.Y = 0;
}
}
}
}
}
详细请参考以下博客:
http://www.codeproject.com/Articles/129329/How-to-Reposition-a-Silverlight-Child-Window
http://ruifigueiredopt.wordpress.com/2011/02/26/dynamically-re-position-a-childwindow/
Mark Yu - MSFT
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.