I am trying to get the X, Y coordinates for a popup menu. I tried:
VisualTreeHelper.GetOffset (Popup);
but the returned vector always contains (0,0) for X and Y.
The parent of the popup is the root of the layout, which is the grid.
CustomPopupPlacementCallback also always returns 0.0 for this Point parameter.
The goal is to allow the user to drag a pop-up window anywhere on the screen. I was going to try to accomplish this by getting the current popup and mouse position, and moving the popup in the same direction of mouse movement.
-------------------- Update --------------------
Chris Nichol, I tried my answer with the following code, but still getting 0.0 for rootPoint:
Xaml:
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="Test.MainWindow" x:Name="Window" Title="MainWindow" Width="800" Height="600"> <Grid x:Name="LayoutRoot"> <Popup x:Name="Popup" IsOpen="True" Placement="Center" Width="100" Height="100"> <Button Click="Button_Click" Content="Test" /> </Popup> </Grid>
Code for:
public partial class MainWindow : Window { public MainWindow() { this.InitializeComponent();
c # wpf xaml popup
gamzu07
source share