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

Use ShapeStyleSelector how to change style dynamic

1 Answer 14 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
rui
Top achievements
Rank 1
rui asked on 20 Apr 2016, 09:05 AM

In my application , i use ShapeStyleSelector  to show diference  style,  the styles is differentiated by  the binding object's property,  the property may change in  app run time, so i need to change the node style dynamic.   at present,   when  user change the property,  i remove the node and add one with another style, This is not a good solution

Is any resolution to resole the problem ?

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 21 Apr 2016, 08:16 AM
Hi Rui,

You can invoke the StyleSelector in code. Please keep in mind that if your Style Setters contain setting of the ContentTemplate - this might not work because of WPF limitation. So you may need to set the ContentTemplate as well:

private void Button_Click_1(object sender, System.Windows.RoutedEventArgs e)
     {
         RadDiagramShape shape = this.xDiagram.Shapes[8] as RadDiagramShape;
         EllipseNode node = shape.DataContext as EllipseNode;
         node.Type = EllipseNodeType.Start;
 
         shape.ContentTemplate = this.Resources["dt1"] as DataTemplate;
         shape.SetValue(RadDiagramShape.StyleProperty, (this.Resources["CustomShapeStyleSelector"] as NodeStyleSelector).SelectStyle(node, shape));
     }



Regards,
Petar Mladenov
Telerik
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
rui
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or