Hopefully this is a quick one for you WPF experts out here. Is there any easy XAML solution to allow my popup to move when the widow moves or changes size? The code is below. If not, I can always handle an event in the code behind.
<Grid>
<Canvas>
<Expander Header="details" HorizontalAlignment="Center" VerticalAlignment="Top" ExpandDirection="Down"
Expanded="Expander_Expanded" Panel.ZIndex="99" Collapsed="Expander_Collapsed" Name="expander">
<Popup PopupAnimation="Slide" Name="popup" Width="200" Height="200" StaysOpen="True" AllowsTransparency="True"
IsOpen="False" >
<Grid Background="Cornsilk">
<Grid.BitmapEffect>
<DropShadowBitmapEffect/>
</Grid.BitmapEffect>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock TextWrapping="Wrap" FontWeight="Bold">
Some example text
</TextBlock>
</Grid>
</Popup>
</Expander>
</Canvas>
</Grid>
Here’s a solution using:
This markup-only sample consists of a text box and a popup. The popup opens when the text box is focused. The popup follows the window as it moves by hooking the window’s location changed event and forcing the popup to reposition itself accordingly.