The code that’s causing this issue is this:

new RootElement(element, NewControlsNotifier);

You are creating a RootElement with new operator but ignored its result. You should either remove object creation completely or use the object you created.

Try this if you want to return your object:

private RootElement GetParentAsRoot(Element element, string method) {
        if (element.Parent == null) {
            return new RootElement(element, NewControlsNotifier);
        var root = element.Parent as RootElement;
        if (root == null) {
            throw new ArgumentException(method + " method is applicable only on top-most element");
        return root;

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top