patrick
patrick

Reputation: 16959

Lock a window position to another window?

I am using a transparent borderless WPF window to get around some drawing limitations of my ESRI ArcEngine which is displayed in a WindowsFormHost in a WPF window. When I move the my app window, I want to move the transparent window at the same time. Is there a way to snap these two windows together so they move together?

Upvotes: 1

Views: 1327

Answers (1)

Paul Sasik
Paul Sasik

Reputation: 81459

There is no facility for "snapping" windows together per se but you can accomplish the same thing very effectively by event handling:

  • handle the size change event of the parent window
  • handle the location change event of the parent window
  • For any of the above-listed events:
    • update the size and location of the child window to that of the parent window

It sounds hacky, and it is, but works pretty seamlessly. Windows size and move events fire often enough that your windows will look glued together.

Upvotes: 1

Related Questions