Adding resize handles to RadDiagramShape

1 Answer 119 Views
Diagram
Burl
Top achievements
Rank 1
Burl asked on 16 Dec 2021, 09:43 PM

Is it possible to add resize handles to a RadDiagramShape object, so it would look something like this?

1 Answer, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 21 Dec 2021, 02:51 PM

Hello Burl,

This behavior is not supported out of the box, however, you could still try to achieve it by creating a custom ManipulationAdorner and handling the resizing of the additional handlers manually. A good example that shows this is the Swimlane demo from our WPF Controls Examples application.

With that said, the following code snippet, from the Swimlane demo, shows how to add handlers to the control template of a custom ManipulationAdorner control:

<Style TargetType="swimlane:CustomManipulationAdorner">
    ......
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="swimlane:CustomManipulationAdorner">
            ....
                <Rectangle x:Name="BottomMiddleResizeHandle"
                       Margin="{StaticResource ManipulationAdornerThicknessB}"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Bottom"
                       Style="{StaticResource rectangleStyle}"
                       Visibility="{Binding RelativeSource={RelativeSource TemplatedParent},
                                            Path=IsResizingEnabled,
                                            Converter={StaticResource converter}}">
                    <ToolTipService.ToolTip>
                        <ToolTip telerik:LocalizationManager.ResourceKey="Diagram_Resize" />
                    </ToolTipService.ToolTip>
                </Rectangle>
                <Rectangle x:Name="TopMiddleResizeHandle"
                       Margin="{StaticResource ManipulationAdornerThicknessB}"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Top"
                       Style="{StaticResource rectangleStyle}"
                       Visibility="{Binding RelativeSource={RelativeSource TemplatedParent},
                                            Path=IsResizingEnabled,
                                            Converter={StaticResource converter}}">
                    <ToolTipService.ToolTip>
                        <ToolTip telerik:LocalizationManager.ResourceKey="Diagram_Resize" />
                    </ToolTipService.ToolTip>
                </Rectangle>
            ....
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

And then handle the logic in code-behind:

public class CustomManipulationAdorner : ManipulationAdorner
{
    private Rectangle bottomMiddleHandle;
    private Rectangle topMiddleHandle;
    public override void OnApplyTemplate()
    {
        base.OnApplyTemplate();
        this.bottomMiddleHandle = GetTemplateChild("BottomMiddleResizeHandle") as Rectangle;
        this.topMiddleHandle = GetTemplateChild("topMiddleResizeHandle") as Rectangle;
    }
.............
}

I hope that you find this a good starting point for achieving your requirements.

Regards,
Stenly
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Diagram
Asked by
Burl
Top achievements
Rank 1
Answers by
Stenly
Telerik team
Share this question
or