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

how to add dynamically ContentTemplete to RadDiagramShape ?

2 Answers 93 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Sopan
Top achievements
Rank 1
Sopan asked on 19 Aug 2013, 10:07 AM
HI,

I want to add the RadDiagramShape dynamically to RadDiagram control but wants to change the ContentTemplete.
<telerik:RadDiagram x:Name="myDiagram">
 
 </telerik:RadDiagram
private void btnAddNewShape_Click(object sender, System.Windows.RoutedEventArgs e)
       {
           DataTemplate templete = new DataTemplate(typeof(RadRichTextBox));
 
           this.myDiagram.AddShape(new RadDiagramShape() { });
       }


But the content editor not show RadRichTextBox, It show normal Content Property as String.


So How to add dynamically ContentTemplete of RadDiagramShape


Thanks

Sopan Vaidya

2 Answers, 1 is accepted

Sort by
0
Zarko
Telerik team
answered on 21 Aug 2013, 02:45 PM
Hi Sopan,
You don't see a RadRichTextBox because you've set the DataType of your DataTemplate(DT) not its content. It's not a common practice go set DTs in code-behind but if you want to it is possible:
1) you could get a DT resource and set it.
2) you could create your own DT in code using the FrameworkElementFactory.
I've attached a sample project showing both approaches so you could decide which one is better for you.
Just one question - do you really need to set the ContentTemplatate ? Why don't you set the Content directly:
newShape.Content = new RadRichTextBox();
I hope I was able to help you and if you have more questions feel free to ask.

Regards,
Zarko
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Sopan
Top achievements
Rank 1
answered on 22 Aug 2013, 04:16 AM
Thank you Zarko  this demo too helped me.
Tags
Diagram
Asked by
Sopan
Top achievements
Rank 1
Answers by
Zarko
Telerik team
Sopan
Top achievements
Rank 1
Share this question
or