Node Location

I am a beginner in GoXam. I have created the following user control Using Diagram Control.

I am using the Observable collection for binding the Diagram. I have used “location” property to bind the location of each node. In my requirement I have two modes. In the first mode user control should show all the nodes(Figure 1). In second mode the user control should show only the node with Id B3 (drawn in Red Circle). I have implemented this feature.(Figure 2)

The Problem is the location of B3 node seems to change. In the second mode, the B3 node seems to moved top left of the screen.

Actually I am using same observable collection to bind the second mode.

IEnumerable<Entity> matches = _lstEntity.Where(p => p.Visibility);

tmpEntity = new ObservableCollection<Entity>(matches);

I am just filtering the collection based on some condition.

Location of B3 in Second mode should same as the Location of B3 in first Mode.

How can I achieve this?

Thanks In Advance

Regards,
Ranish

It’s entirely possible that B3’s Node.Location is the same – it’s just that the diagram has scrolled. You can check the value of Diagram.Panel.Position to see if that’s the case.

What’s the value of Diagram.HorizontalContentAlignment and VerticalContentAlignment? You probably want to set those to “Stretch”.

<p style=“margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none;” =“Msonormal”>Hi,


Thank You for response.<p style=“margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none;” =“Msonormal”>I have checked the B3 node’s location in both modes and both location values are same.( X: 100.0 , Y:
60.0). Also I have checked Diagram.HorizontalContentAlignment and
VerticalContentAlignment values . Currently the values are
HorizontalContentAlignment=“Left” and VerticalContentAlignment=“Top”. I set those to "Stretch”. But
then node location changed to Centre of the Diagram control. <?: prefix = o ns = “urn:schemas-microsoft-com:office:office” /><o:p></o:p>

<p style=“margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none;” =“Msonormal”><o:p> </o:p>

<p style=“margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none;” =“Msonormal”>I actually want
B3 location as same as in first mode.

Regards,

Ranish

Your old …ContentAlignment values were what was causing the diagram to scroll the diagram’s bounds (i.e. Diagram.Panel.DiagramBounds) to the top-left corner of the viewport.

Whatever value you had for Diagram.Panel.Position before filtering should be the same as the value afterwards. That will cause the new nodes to be in the same viewport position as the corresponding old nodes.

This brings up the issue of how you are implementing the filtering. You didn’t say how you are doing it. I’m guessing that you are replacing the Diagram.Model.NodesSource collection with a new collection. That will cause the diagram to be rebuilt, discarding the old nodes and building new ones.

However, wouldn’t it make more sense to just toggle the Part.Visible property for each of the nodes, as you see fit?

Hi

Thank you for your response.

I am using same observable collection list to both modes. I have used following code to bind

private ObservableCollection<Entity> _lstEntity; //for nodes

private ObservableCollection<Transition> _lstTransition; //for links

var model = new GraphLinksModel<Entity, String, String, Transition>();

……..

……..

model.NodesSource = _lstEntity;

model.LinksSource = _lstTransition;

myDiagram.Model = model;

I just applied some filtering in the old list(binded in first mode) for the second mode.

But the location of need seems to changed.

At last I have removed filtering from the list and binded entire list in both mode’s and just handle the visibility of the Node in the second Mode. Then its seems working fine.

If any other alter solution for solve this issue ,Please let me know

Regards,
Ranish