Use ShapeStyleSelector how to change style dynamic

2 posts, 0 answers
  1. rui
    rui avatar
    55 posts
    Member since:
    May 2014

    Posted 20 Apr 2016 Link to this post

    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 ?

  2. Petar Mladenov
    Petar Mladenov avatar
    2991 posts

    Posted 21 Apr 2016 Link to this post

    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));

    Petar Mladenov
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top