我正在使用http://wpfmdi.codeplex.com/库来处理我的WPF应用程序中的MDI。
我有一个包含子容器的Canvas
,所有小窗口都放在这里。我希望窗口在x = 500,y = 500的位置打开。但是,对于我当前的代码,窗口始终在画布的左上角打开。
下面我粘贴了我的XAML以及在画布中打开一个新窗口的代码。
<Canvas Name="cnvsMain" Background="LightGray" AllowDrop="True" Drop="cnvsMain_Drop">
<mdi:MdiContainer Name="mainContainer" Background="LightGray">
</mdi:MdiContainer>
</Canvas>
TableWindow tableWindow = new TableWindow(tableName);
listTableWindows.Add(tableWindow);
mainContainer.Children.Add(new MdiChild()
{
MaximizeBox = false,
MinimizeBox = false,
Resizable = true,
ShowIcon = false,
Title = "X",
Position = new Point(500,500),
Content = tableWindow.Content as UIElement //Opens new instance of my window class
});
有什么想法吗?我也试过从我的窗口类中设置位置,但没有用。
答案 0 :(得分:2)
因为我没有使用那个特定的库,而是
,所以只是在这里吐痰mainContainer.Children.Add(new MdiChild()
{
MaximizeBox = false,
MinimizeBox = false,
Resizable = true,
ShowIcon = false,
Title = "X",
Position = new Point(500,500),
Content = tableWindow.Content as UIElement //Opens new instance of my window class
});
你试过吗
var child = new MdiChild
{
MaximizeBox = false,
MinimizeBox = false,
Resizable = true,
ShowIcon = false,
Title = "X",
Position = new Point(0, 0),
Content = tableWindow.Content as UIElement //Opens new instance of my window class
};
mainContainer.Children.Add(child);
child.Position = new Point(500, 500);
// or
//child.Margin = new Thickness(500, 500, 0, 0);