Rulers in WPF Diagram (SfDiagram)
11 Jan 20241 minute to read
The Ruler provides a Horizontal and Vertical guide for measuring in the Diagram control. The Ruler can be used to measure the Diagram objects, indicate positions, and align Diagram elements. This is especially useful in creating scale models. You can set the unit of measure, such as centimeters or inches. The default Unit of measure is pixels.
Please refer to the sample from Dashboard->Desktop->WPF->Diagram->GettingStarted->Rulers and Units.
Define Rulers
xmlns:Syncfusion="clr-namespace:Syncfusion.UI.Xaml.Diagram;assembly=Syncfusion.SfDiagram.WPF"
xmlns:SyncControls="clr-namespace:Syncfusion.UI.Xaml.Diagram.Controls;assembly=Syncfusion.SfDiagram.WPF"
<syncfusion:SfDiagram x:Name="diagram">
<syncfusion:SfDiagram.HorizontalRuler>
<syncfusion:Ruler/>
</syncfusion:SfDiagram.HorizontalRuler>
<syncfusion:SfDiagram.VerticalRuler>
<syncfusion:Ruler Orientation="Vertical"/>
</syncfusion:SfDiagram.VerticalRuler>
</syncfusion:SfDiagram>
diagram.HorizontalRuler = new Ruler();
diagram.VerticalRuler = new Ruler() { Orientation = Orientation.Vertical };
Customizing the Ruler
By default, ruler segments are arranged based on the MeasurementUnit
. See the available LengthUnits for Ruler.
Segment width, the textual description of the ruler segment, and the appearance of the ruler ticks can be customized.
Please refer to the sample to Customize the Ruler.