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

RadDiagramTextShape - the same font size in edit and normal mode

3 Answers 91 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 23 Jul 2016, 07:29 AM

Hello,

I having problem with RadDiagramTextShape font size when it is editing. I need to RadDiagramTextShape font size in edit mode is equal to font size in normal state. I don't see any relationship between the font size in normal mode and edit mode (see attach file). I think currently font size is fixed value in edit mode. 

How I can binding/set size font in edit mode to equal in normal mode?

 

Thanks you

Adam

3 Answers, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 27 Jul 2016, 07:59 AM
Hi Adam,

In order to have equal sizes for the RadDiagramTextShape's font size and the one used in edit mode, use the EditTemplate property of the shape. For instance:
<telerik:RadDiagram x:Name="diagram">
            <telerik:RadDiagramTextShape Content="This is a text shape" Position="20, 40" FontSize="24">
                <telerik:RadDiagramTextShape.EditTemplate>
                    <DataTemplate>
                        <TextBlock
                            FontSize="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadDiagramTextShape}, Path=FontSize}"
                            Text="{Binding}"/>
                    </DataTemplate>
                </telerik:RadDiagramTextShape.EditTemplate>
                 
            </telerik:RadDiagramTextShape>
            <telerik:RadDiagramShape Content="this is a simple shape" Position="40, 80">
                 
            </telerik:RadDiagramShape>
        </telerik:RadDiagram>
I am binding the font size of the TextBlock in my DataTemplate to the font size of the RadDiagramShape's element.

Hope this helps.

Regards,
Peshito
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Adam
Top achievements
Rank 1
answered on 09 Aug 2016, 01:16 PM

Hi Peshito,

Thank you for this code. Why do you use TextBlock in DataTemplate? When I use TextBlock in DataTemplate I can't edit RadDiagramTextShape (after double click RadDiagramTextShape change to not editable TextBlock). I change it to TextBox and it is working now, but TextBox isn't focused after double click and cursor isn't at the end of editable TextBox. How can I change it? 

 

<DataTemplate>
        <TextBox TextWrapping="Wrap" AcceptsReturn="True"
                            FontSize="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadDiagramTextShape}, Path=FontSize}"
                            Text="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadDiagramTextShape}, Path=Content}"/>
</DataTemplate>

0
Peshito
Telerik team
answered on 10 Aug 2016, 08:32 AM
Hello Adam,

I have mistaken the TextBlock with the TextBox in the DataTemplate. This approach seems not to be the best one. Using shape's EditTemplate will require further work to mimic the default diagram's behavior for the shape because this way a whole new custom template will be used. This is why I would suggest another one. Simply attach to shape's loaded event as shown below:
private void RadDiagramTextShape_Loaded(object sender, RoutedEventArgs e)
{
        RadDiagramTextShape shape = sender as RadDiagramTextShape;
        TextBox tBox = shape.ChildrenOfType<TextBox>().FirstOrDefault();
        tBox.FontSize = shape.FontSize;
}
This way the DiagramTextShape will act as if the FontSize was changing correctly in edit mode. I logged this as a bug report in our feedback portal. Here is the link where you can follow its progress and vote for it in order to rise its priority.

Regards,
Peshito
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
Diagram
Asked by
Adam
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Adam
Top achievements
Rank 1
Share this question
or