Hi,
I'm trying to make the RadDiagram behave as shown here: Mock up screenshot
Here's how far I got on my own: Actual screenshot
I need:
1. The connectors to be aligned to the top left/right, and not scaled
2. Labels for the connectors (not connection) to be inside the shape
3. To generate the connectors during run time (eg, via DataBinding)
1. The connectors to be aligned to the top left/right, and not scaled
By following the custom connector guide, I am able to generate custom connectors.
However, since connectors are placed using offsets, my connectors are stretched/shrinked as the shape resizes
How can I overcome this?
2. Labels for the connectors (not connection) to be inside the shape
I am doing this by overridding the RadDiagramConnector's ControlTemplate.
I'm using a value converter to determine the order the connector ellipse/label, and am currently stuck trying to make sure the label is within the shape.
Is there an easier way to do this?
3. To generate the connectors during run time (eg, via DataBinding)
I tried extending the RadDiagramShapeBase class, and provided my own DependencyProperty.
But I noticed that once the shape is loaded, any changes to the RadDiagramShapeBase.Connectors collection no longer updates the visual.
Right now, I'm working around this by passing in the data context via the constructor.
How can I do this via data binding?
Please help.
Thanks!
Josh
I'm trying to make the RadDiagram behave as shown here: Mock up screenshot
Here's how far I got on my own: Actual screenshot
I need:
1. The connectors to be aligned to the top left/right, and not scaled
2. Labels for the connectors (not connection) to be inside the shape
3. To generate the connectors during run time (eg, via DataBinding)
1. The connectors to be aligned to the top left/right, and not scaled
By following the custom connector guide, I am able to generate custom connectors.
However, since connectors are placed using offsets, my connectors are stretched/shrinked as the shape resizes
How can I overcome this?
2. Labels for the connectors (not connection) to be inside the shape
I am doing this by overridding the RadDiagramConnector's ControlTemplate.
I'm using a value converter to determine the order the connector ellipse/label, and am currently stuck trying to make sure the label is within the shape.
Is there an easier way to do this?
3. To generate the connectors during run time (eg, via DataBinding)
I tried extending the RadDiagramShapeBase class, and provided my own DependencyProperty.
But I noticed that once the shape is loaded, any changes to the RadDiagramShapeBase.Connectors collection no longer updates the visual.
Right now, I'm working around this by passing in the data context via the constructor.
How can I do this via data binding?
public
static
readonly
DependencyProperty ConnectorsSourceProperty =
DependencyProperty.Register(
"ConnectorsSource"
,
typeof
(IList<Argument>),
typeof
(ActivityShape),
new
PropertyMetadata((sender, e) => ((ActivityShape)sender).BuildConnectors((IList<Argument>) e.NewValue)));
public
IList<Argument> ConnectorsSource
{
get
{
return
(IList<Argument>)GetValue(ConnectorsSourceProperty); }
set
{ SetValue(ConnectorsSourceProperty, value); }
}
private
void
BuildConnectors(IList<Argument> arguments)
{
var inputs = arguments.Where(a => a.Direction == Direction.In).ToArray();
var outputs = arguments.Where(a => a.Direction == Direction.Out).ToArray();
var inputDelta = 1.0 / (inputs.Length + 1);
var outputDelta = 1.0 / (outputs.Length + 1);
Connectors.Clear();
for
(
int
i = 0; i < inputs.Length; i++)
{
var argument = inputs[i];
Connectors.Add(
new
RadDiagramConnector
{
Name = argument.Name,
Offset =
new
Point(0, inputDelta*(i + 1))
});
}
for
(
int
i = 0; i < outputs.Length; i++)
{
var argument = outputs[i];
Connectors.Add(
new
RadDiagramConnector
{
Name = argument.Name,
Offset =
new
Point(1, outputDelta*(i + 1))
});
}
}
Please help.
Thanks!
Josh