title: WPF Detecting final placement of Popup
body: <p>Is it possible to detect the final placement of a popup window? I have a custom popup that renders below a specified UI element and I would like it to draw a border relative to its position to the specified UI control. By default the behaviour is ok, such that the popup is drawn below the control.<br /> However as per the popup behaviour if it encounters a screen edge the pop is drawn at a different location. My question is there away to detect were the popups finally position is and then draw the borders respective to its new location.<br /> Or does this require a manual process to work out if the popup was drawn in a different location than its default placement.</p>
  
  <p><strong>EDIT</strong><br />
  Below is a picture from Git Extensions as you see there is no line seperating "dev" from the rest of the drop down. Now I have been able to replicate this behaviour all happily. However popups have this neat feature where if the encounter a screen edge the popup will shift <a href="http://msdn.microsoft.com/en-us/library/bb613596%28v=vs.110%29.aspx#When" rel="nofollow noreferrer">accordingly</a>, no this is were my issue comes in because when the popup is shift or rendered at another point I need to pick up this shift and draw the popups borders appropriately. i.e so that if that selection options is popup is drawn above the dev button the the top of the popup will have a complete line and the bottom will have the appropriate gap (sorry no picture example). When I get a chance I will draw an example.</p>
  
  <p>I hope the edit helps :)</p>
  
  <p><img src="https://i.stack.imgur.com/HSrBG.jpg" alt="enter image description here"></p>