我想做这样的事情-
标注的中间应与列表视图项的中间对齐。如何找到列表视图项目中间的实际坐标,以便我可以对齐只是一个路径元素的标注?
你必须做这样的事情:
为 ListView 的选择更改事件创建处理程序。在该句柄中放入以下代码:
// step 1. Get selected item's container (ListViewItem in case of ListView)
var dependencyObject = listView.ItemContainerGenerator.ContainerFromIndex(listView.SelectedIndex);
var listViewItem = dependencyObject as Windows.UI.Xaml.Controls.ListViewItem;
// step 2. transform items rectangle into coordinates of containing control
var transform = listViewItem.TransformToVisual(parentContainer);
var rect = transform.TransformBounds(new Rect(0, 0, itemsControl.ActualWidth, itemsControl.ActualHeight));
var center = (rect.Top + rect.Bottom) / 2;
// step 3. position callout using center value calculated above
// exact code depends on you container, ie. Grid, Canvas, etc.