Hi,
thanks for your reply. For the sake of simplicity I only copy & pasted the important parts of the code.
The more detailed code would be:
I first load the kml file with an open file dialog. And when the loading succeeds, I create the dataset and the layer:
string path = openFileDialog.FileName;
Uri kmlUri = new Uri(path);
KmlDataset dataset = new KmlDataset(kmlUri);
KmlLayer layer = new KmlLayer(dataset);
MyMapView.Map.OperationalLayers.Add(layer);
await LoadKmlData(dataset);
The method LoadKmlData would add all the KmlNodes to the WPF/XAML TreeView:
await dataset.LoadAsync();
foreach (KmlNode kmlRootNode in dataset.RootNodes)
{
TreeViewItem treeViewItem = new TreeViewItem(kmlRootNode, null);
treeViewItems.Add(treeViewItem);
TreeViewItem.AddChildrenItemsToRootItem(treeViewItem);
}
TreeView.ItemsSource = treeViewItems;
The TreeView shows all the items from my kml file correctly. When I click on a TreeView item, I would like to get the Geometry of that item by the Event handler TreeView_SelectedItemChanged:
TreeViewItem selectedItem = e.NewValue as TreeViewItem;
if(selectedItem != null)
{
KmlNode node = selectedItem.Node;
if(node.GetType() == typeof(KmlPlacemark))
{
Geometry geometry = ((KmlPlacemark)node).Geometry;
}
}
But unfortunately the geometry is null.