There is no support for Binding the Route.Points property, but are you saving the points in your model data?
I use GoXAM build in for my link model where i derive. - This already has Points property, which i just use.
I do not directly bind from XAML to that specific point at runtime.
Build in UpdateRouteDataPoints should update the layout, or am i missunderstanding things?
OK, so you are using a custom PartManager in the same way that the Draggable Link sample does.
PartManager.UpdatesRouteDataPoints controls whether a change to the “Points” property of a link data object updates the Route.Points property of the corresponding Link. It has no effect on layouts.
Yes i use a custom PartManager, in the same ways that the Draggable Link sample does.
Walter, is there any chance that we could communicate via Skype so that i simply screen-share my problem? - I guess with that i would achieve a faster solution.
Thanks for reporting this problem. It does seem to be a bug. I think the problem is caused by some missing updates of internal data structures that occur in certain sequences of events. We’re still investigating a solution.
Hi Walter, i tested the 304-alpha2-net6.0 assembly which you have me provided.
See my user story below:
-
Created two nodes, and made two links connecting them
-
Selected all by CTRL +A, then CTRL + C and then CTRL +V
Seems like the “Curviness” is calculated correctly, but the it seems like by “Berzier” Curve setting, from my only link template is not kept in mind:
Ok, i am not able to reproduce this behavior in the GoWPF sample using your new assembly. - I will investigate on my side.
Ok, i found the reason for my behavior, it seems that i am making something wrong by manipulating the style:
<!--<Style TargetType="{x:Type go:Node}">
<Setter Property="IsSelected" Value="{Binding Path=Data.IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</Style>
<Style TargetType="{x:Type go:Link}">
<Setter Property="IsSelected" Value="{Binding Path=Data.IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</Style>-->
<!--#endregion-->
If i have those style commented, everything works as expected. - But i want to have the selection bound to my model. - Any ideas?
That’s odd. I’ll try it.
I wonder if that can work. Here’s one thing that I have tried:
public class CustomNode : Node {
static CustomNode() {
// This attached property should be set on the Part.VisualElement of the CustomNode.
// It exists to allow data binding in the DataTemplate.
SelectedProperty = DependencyProperty.RegisterAttached("Selected", typeof(bool), typeof(CustomNode),
new FrameworkPropertyMetadata(false, OnSelectedChanged));
}
public static readonly DependencyProperty SelectedProperty;
public static bool GetSelected(DependencyObject d) { return (bool)d.GetValue(SelectedProperty); }
public static void SetSelected(DependencyObject d, bool v) { d.SetValue(SelectedProperty, v); }
// Changes to this attached property get passed on to Part.IsSelected
private static void OnSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
Part p = Part.FindAncestor<Part>((FrameworkElement)d);
if (p != null) {
p.IsSelected = (bool)e.NewValue;
}
}
// Changes to Part.IsSelected get passed on to the CustomNode.Selected attached property on the VisualElement
protected override void OnIsSelectedChanged() {
base.OnIsSelectedChanged();
var root = this.VisualElement;
if (root != null) SetSelected(root, this.IsSelected);
}
}
and one uses the CustomNode class instead of the usual Node class via customizing the PartManager:
public class CustomPartManager : PartManager {
protected override Node MakeNodeForData(object nodedata, IDiagramModel model, bool isgroup, bool islinklabel, string category, DataTemplate templ) {
Node node = null;
if (isgroup) {
node = new Group();
} else {
node = new CustomNode();
}
PartBinding data = new PartBinding(node, nodedata);
node.Content = data;
node.DataContext = data;
node.ContentTemplate = templ; // for PartManager.MakeNodeForData
node.IsLinkLabel = islinklabel;
if (category != null && category != "") {
if (node.Category != category) node.Category = category;
}
return node;
}
}
Make use of the CustomPartManager when you set up the Diagram:
// deal with data property changes that are not data-bound
myDiagram.PartManager = new CustomPartManager();
I assume you have already successfully added an “IsSelected” or equivalent property to your node data class.
Thank you for this. - We have now fully switched and handle to selection manually within our CustomPartManager and this seems to work fine. - Previously i tried to handle the selection in the ModelChanged => PropertyChanged => IsSelected, but here for example, if i drag a new element, the ModelChanged does not notify a PropertyChanged for IsSelected and there we went asynchronous.
Anyway, as described in the docs, it is job of the PartManager, and he does this very well.
I still got feedback, that some copied links are overlapping in certain situations. - But i did not have time yet for investigations. - I will come back here if i need further assistance.
Are there any scheduled plans when the new assembly version is getting released?