Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
OnToolWindowLoaded example showing undocked panel sizing and positioning

I needed to provide special handling for a large flyout panel in our application. I wanted to resize and reposition the panel if it was undocked in a way that would extend it beyond workable monitor boundaries. This might happen if you unplugged a laptop say, or just positioned the panel mostly off the screen.

I ended up handling this in the ToolWindowLoaded event. I may end up tweaking the size and position code a bit, but it seems to work well with the WPF 10.3 libraries we're using. Here's my sample handler, hope this helps someone out.

// fired when a flyout tab is floated by the user
private void OnToolWindowLoaded(object sender, PaneToolWindowEventArgs e)
  PaneToolWindow toolWindow = e.Window;

  // size restrictions when floating one of the flyout panels
  if ((toolWindow.Pane != null) && (toolWindow.Pane.Panes != null)) {

    var position = 10; // left or top position if we move the window
    var margin = 50; // margin if we need to resize or reposition
    // Primary screen height accounts for taskbar, virtual screen width for multiple monitors
    var maxHeight = SystemParameters.MaximizedPrimaryScreenHeight - margin - position;
    var maxWidth = SystemParameters.VirtualScreenWidth - margin - position;

    // Limit the size of the map pane when flown
    if (toolWindow.Height > maxHeight) {
      toolWindow.Height = maxHeight;
    if (toolWindow.Width > maxWidth) {
      toolWindow.Width = maxWidth;

    // Don't permit the map pane to position itself outside the monitor boundaries
    if ((toolWindow.Top < 0) ||
        ((toolWindow.Top + toolWindow.Height) > SystemParameters.MaximizedPrimaryScreenHeight)) {
          toolWindow.Top = position;
    if ((toolWindow.Left < 0) ||
        ((toolWindow.Left + toolWindow.Width) > SystemParameters.VirtualScreenWidth)) {
          toolWindow.Left = position;

No Data
  • 138253
    Offline posted



    Thank you for the provided information. I believe that other community members may benefit from this as well.


    Thanks again.

No Data