WPF multiwindow application. Determining dimension

2019-09-06 16:17发布

问题:

I have a multi-window application in WPF, where my main application window is invisible (Visibility=Collapsed) containing visible child windows. Application creates child windows on-demand. I need an algorithm to determine the coordinates and dimensions of the newly created child window. Obviously, the new child window should not cover (fully) another child window. Does WPF offer any support whatsoever to implement this kind of logic ? Or, do I have to do everything on my own. I imagine this would be a lot of work. The behavior I am looking for is very similar to Sticky Notes behavior in Windows 7.

Part of my code will help you to really understand what I mean:

public void ViewModelsCollectionChanged(object sender, 
                                        NotifyCollectionChangedEventArgs e)
{
    if (e.Action == NotifyCollectionChangedAction.Add)
    {
        foreach (ViewModel viewModel in e.NewItems)
        {
            View view = new View(viewModel);
            view.Owner = SleekNoteUI.App.Current.MainWindow;
            ...
        }
    }
}