Hi,
I decided to ask here, because after few days I still have no idea how the RadDiagram works.
Here is my code (it's not the whole file, just the most important - in my opinion - parts):
The class above is my GraphSource that is bounded to RadDiagram in xaml. As you can see, I tried to attach handler to link.PropertyChanged event and it worked for a moment, but now I did something wrong, I think. Anyway - when I create link on diagram, the AddLink is invoked for the first time. Target is null, but Source is valid object that connection's going from. When I attach the connection to the destination object, AddLink method is called again, but this time also Target is null, and Source is a object that connection is going to. All of this is very strange and I cannot understand how to work with the connections. As you can see, I need to save each user's action in database (using _commandingProvider), so I need to know when new valid connection is set (valid => if connecting two objects).
I can also show xaml:
I decided to ask here, because after few days I still have no idea how the RadDiagram works.
Here is my code (it's not the whole file, just the most important - in my opinion - parts):
public class OrgGraphSource : ObservableGraphSourceBase<CMSHierarchicalParticipant, CMSHierarchicalParticipantLink> {}public void Populate(CMSOrgStructure orgStructure) { if (orgStructure == null) return; foreach (var item in orgStructure.Participants) base.AddNode(item); foreach(var link in orgStructure.ParticipantLinks) base.AddLink(link); }public override void AddNode(CMSHierarchicalParticipant participant) { _commandingProvider.AddParticipantToOrgStructure(_ownerId, _authorId, ServiceConverter.Convert(participant)); base.AddNode(participant); participant.PropertyChanged += Node_PropertyChanged; }public override bool RemoveItem(CMSHierarchicalParticipant participant) { participant.PropertyChanged -= Node_PropertyChanged; bool itemRemoved = base.RemoveItem(participant); if (itemRemoved) { _commandingProvider.RemoveParticipantFromOrgStructure(_ownerId, _authorId, ServiceConverter.Convert(participant)); } return itemRemoved; }public override void AddLink(CMSHierarchicalParticipantLink link) { link.PropertyChanged += link_PropertyChanged; base.AddLink(link); } void link_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { var link = sender as CMSHierarchicalParticipantLink; if (link == null || link.Source == null || link.Target == null) return; _commandingProvider.AddLinkInOrgStructure(_ownerId, _authorId, ServiceConverter.Convert(sender as CMSHierarchicalParticipantLink)); }
The class above is my GraphSource that is bounded to RadDiagram in xaml. As you can see, I tried to attach handler to link.PropertyChanged event and it worked for a moment, but now I did something wrong, I think. Anyway - when I create link on diagram, the AddLink is invoked for the first time. Target is null, but Source is valid object that connection's going from. When I attach the connection to the destination object, AddLink method is called again, but this time also Target is null, and Source is a object that connection is going to. All of this is very strange and I cannot understand how to work with the connections. As you can see, I need to save each user's action in database (using _commandingProvider), so I need to know when new valid connection is set (valid => if connecting two objects).
I can also show xaml:
<telerik:RadDiagram x:Name="OrgChart" Grid.Column="2" IsEnabled="{Binding IsEnabled}" GraphSource="{Binding GraphSource}" SelectedItem="{Binding SelectedPerson, Mode=TwoWay}" ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible" IsConnectorsManipulationEnabled="True" IsManipulationAdornerVisible="True" ShapeStyle="{StaticResource DiagramNodeStyle}" ConnectionStyle="{StaticResource DiagramEdgeStyle}" /> And of course CMSHierarchicalParticipantLink implements ILink<CMSHierarchicalParticipant>... I would appreciate any help you can provide me with, thank you in advance. Paweł