Search code examples
c#uwpwindows-runtimedependencyobject

UWP LogicalTreeViewHelper


I'm trying to convert an library from wpf to uwp. I'm almost done but now there is the LogicalTreeViewHelper which doesn't exist in UWP anymore.

does anyone know how to replace it in uwp?

var parent = LogicalTreeHelper.GetParent(MyDependencyObject);

Solution

  • In UWP, you should use the VisualTreeHelper class instead.

    There are quite a few toolkits and helpers around to do this, I personally have my Cimbalino Toolkit which provides direct extension methods so you could just do:

    var parent = MyDependencyObject.GetVisualParent();
    

    For this to work, you can either go the simple route add the NuGet package to your solution or just take the bits you need from the source code