How to add search links in Layer?

Hi,

I have created a layer in my xDiagram. How can I add & search MyLinkData objects in this layer to perform some action later.

Please refer my sample code:

void

xDiagram_TemplateApplied(object sender, DiagramEventArgs e)

{

var layer = new LinkLayer();

layer.Id =

"TempLinkLayer";

xDiagram.Panel.Children.Insert(0, layer);

}

Just iterate over the LinkLayer.Links collection and look at the Link.Data property, cast to your MyLinkData type.

Hi,

This is fine for searching.

But how to add links in this layer?

I assume you know how to add links to a diagram at all – through adding link relationship information to the model.

So you just need to make sure that the go:Link.LayerName == “TempLinkLayer”. Typically that attached property is either set or data bound in the DataTemplate on the root FrameworkElement.

Hi,

Yes, I know how to add objects in diagram.

But I have created my own ‘MyLinkData’ class, which has no property like go:Link.LayerName

So haw can I access go:Link propertis in my own ‘MyLinkData’ class?

public

class MyLinkData : GraphLinksModelLinkData<String, String>


{}

Do you need to change the layer that a Link is in dynamically? If so, then it might make sense to add a LayerName property to your MyLinkData class and bind go:Part.LayerName to that property.

But if not, then I would not bother with a new property and binding, but just set go:Part.LayerName=“TempLinkLayer” in the DataTemplate.

Hi,

Thanks for your hint.
It worked.