Unbound node doesn't get the location set to it


I am trying to add a unbound node programatically, as shown in the below code. But I see that the node is taking NaN for the location and appears at left top corner. Also it doesn’t appear on diagram by default rather its shown only after after I zoom in /zoom out.

        Node annotationNode = new Node
            Location = new Point(125,125),
            Id = "1",

Note that the values to Location comes from another layer in out application and also the id

The Node.Location attached property is stored on the Part.VisualElement. But if you just create a Node via the constructor, it won’t have any visual tree because it hasn’t been copied from a DataTemplate, so there won’t be any place to keep the Location or any other attached property.

You could try fist setting its ContentTemplate to the DataTemplate instance that you want to use.