SetShapeStyle Commands in WPF Diagram (SfDiagram)

5 May 20211 minute to read

The SetShapeStyle command is used to set a specific style for the selected elements in the diagram.

<Style TargetType="Path" x:Key="SetShapeStyleParameter">
  <Setter Property="Stretch" Value="Fill"></Setter>
  <Setter Property="Fill" Value="Green"></Setter>

<Button Height="50" Content="SetShapeStyle" Name="SetShapeStyle" Command="Syncfusion:DiagramCommands.SetShapeStyle" CommandParameter="{StaticResource SetShapeStyleParameter}"></Button>
Style style = new Style();
style.Setters.Add(new Setter() { Property = System.Windows.Shapes.Path.FillProperty, Value = new SolidColorBrush(Colors.Green) });
style.Setters.Add(new Setter() { Property = System.Windows.Shapes.Path.StretchProperty, Value = Stretch.Fill });

IGraphInfo graphinfo = diagramcontrol.Info as IGraphInfo;

Gif for SelectByType command

View sample in GitHub