This is a migrated thread and some comments may be shown as answers.

How to resize a shape with custom ShapeTemplate in ShapeTemplateSelector

3 Answers 184 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
rui
Top achievements
Rank 1
rui asked on 07 Jun 2018, 11:50 AM

I use ShapeTemplateSelector to design some different shape,   to resize the shape , I add Thumb in the DataTemplate,it is inefficient

I wish to resize a shape by the diagram‘s ’native behavior  but  the  shape is not resize by the outer rectangle

How to resolve it 

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 12 Jun 2018, 08:51 AM
Hi Rui,

Thanks for the provided image.

Can you please check out the Disable Horizontal or Vertical Resizing help article, as this topic is discussed in details in it?

I hope yo find it helpful.

Regards,
Stefan
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
rui
Top achievements
Rank 1
answered on 12 Jun 2018, 09:26 AM

Hi Stefan

Thanks for your reply

I solve the problem by resizing event

int the event method  i set the shape's  width or height binding value as the bounds's width or height,the code is as follow

void CustomResizingService_Resizing(object sender, ResizingEventArgs e)
        {
            foreach (var item in _selectedItems)
            {
                var shape = item as RadDiagramShape;
                if (shape == null) continue;
                var squidNode = shape.DataContext as SquidNode;
                squidNode.Squid.Location_x = (int)item.Bounds.X;
                squidNode.Squid.Location_y = (int)item.Bounds.Y;
                squidNode.Squid.Squid_width = item.Bounds.Width;
                squidNode.Squid.Squid_height = Math.Max(item.Bounds.Height, squidNode.MinHeight);  
            }
        }

<Style x:Key="SquidShapeStyle"
           TargetType="telerik:RadDiagramShape">
       <Setter Property="Width"
                Value="{Binding Squid.Squid_width,Mode=TwoWay}" />
        <Setter Property="Height"
                Value="{Binding Squid.Squid_height,Mode=TwoWay}" />

           ...
    </Style>

I think,when resizeing, the shape's width and height  should auto change without above code ,

Did I miss anything important?

 

0
Stefan
Telerik team
answered on 15 Jun 2018, 08:30 AM
Hi Rui,

Thanks for the update.

I cannot confirm the exact cause for this behavior, as there seems to be a customization of which I am not aware. Can you please double check whether there isn't some Margin applied within the customized template, as this is my best guess for the selection rectangle being around the shape. Although the solution you have found might be working as expected, placing the control within a ViewBox, for example, might do the trick out of the box.

Regards,
Stefan
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
Diagram
Asked by
rui
Top achievements
Rank 1
Answers by
Stefan
Telerik team
rui
Top achievements
Rank 1
Share this question
or