팝업 컨트롤의 X, Y 좌표를 가져 오려고합니다. 나는 시도했다 :WPF 팝업 컨트롤 - X, Y 좌표 찾기
VisualTreeHelper.GetOffset (Popup); X와 Y
팝업의 부모에 대한
하지만 벡터가 항상 포함되어 반환 (0,0) 그리드 인 레이아웃 루트입니다.CustomPopupPlacementCallback은 항상 Point 매개 변수에 대해 0,0을 반환합니다.
목표는 사용자가 화면 어디에서나 팝업을 드래그 할 수있게하는 것입니다. 나는 현재 팝업 및 마우스 위치를 가져 와서 마우스 이동과 동일한 방향으로 팝업을 이동하여이를 수행하려고했습니다.
-------------------- 업데이트 --------------------
Chris 니콜, 나는 다음 코드로 답변을했지만, 여전히 rootPoint 0,0를받을 수있다 :
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>
코드 뒤에 :
public partial class MainWindow : Window
{
public MainWindow()
{
this.InitializeComponent();
// Insert code required on object creation below this point.
}
private void Button_Click(object sender, RoutedEventArgs e)
{
GeneralTransform transform = Popup.TransformToAncestor(LayoutRoot);
Point rootPoint = transform.Transform(new Point(0, 0));
}
}
,451,515,
같은 문제가 있습니다. 해결책을 찾았습니까? 친절한 답변 – Cinaird
해결책을 찾지 못했습니다. 오래 지연되어서 죄송합니다. – gamzu07
좋아요, 답변 해 주셔서 감사합니다 – Cinaird