SetShapeStyle Commands in WPF Diagram (SfDiagram)

27 Jun 20241 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>
</Style>

<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;
graphinfo.Commands.SetShapeStyle.Execute(style);

Gif for SelectByType command

View sample in GitHub