menu

WPF

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class SfBadge - WPF API Reference | Syncfusion

    Show / Hide Table of Contents

    Class SfBadge

    Inheritance
    System.Object
    SfBadge
    Namespace: Syncfusion.Windows.Controls.Notification
    Assembly: Syncfusion.Tools.Wpf.dll
    Syntax
    public class SfBadge : ContentControl

    Constructors

    SfBadge()

    Initializes a new instance of the SfBadge class.

    Declaration
    public SfBadge()

    Fields

    AnimationTypeProperty

    Identifies AnimationType dependency property.

    Declaration
    public static readonly DependencyProperty AnimationTypeProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    BadgeProperty

    Identifies BadgeProperty attached property.

    Declaration
    public static readonly DependencyProperty BadgeProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    CustomShapeProperty

    Identifies CustomShape dependency property.

    Declaration
    public static readonly DependencyProperty CustomShapeProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    FillProperty

    Identifies Fill dependency property.

    Declaration
    public static readonly DependencyProperty FillProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    HorizontalAnchorPositionProperty

    Identifies HorizontalAnchorPosition dependency property.

    Declaration
    public static readonly DependencyProperty HorizontalAnchorPositionProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    HorizontalAnchorProperty

    Identifies HorizontalAnchor dependency property.

    Declaration
    public static readonly DependencyProperty HorizontalAnchorProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    HorizontalPositionProperty

    Identifies HorizontalPosition dependency property.

    Declaration
    public static readonly DependencyProperty HorizontalPositionProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    ShapeProperty

    Identifies Shape dependency property.

    Declaration
    public static readonly DependencyProperty ShapeProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    StrokeProperty

    Identifies Stroke dependency property.

    Declaration
    public static readonly DependencyProperty StrokeProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    StrokeThicknessProperty

    Identifies StrokeThickness dependency property.

    Declaration
    public static readonly DependencyProperty StrokeThicknessProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    VerticalAnchorPositionProperty

    Identifies VerticalAnchorPosition dependency property.

    Declaration
    public static readonly DependencyProperty VerticalAnchorPositionProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    VerticalAnchorProperty

    Identifies VerticalAnchor dependency property.

    Declaration
    public static readonly DependencyProperty VerticalAnchorProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    VerticalPositionProperty

    Identifies VerticalPosition dependency property.

    Declaration
    public static readonly DependencyProperty VerticalPositionProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    Properties

    AnimationType

    Gets or sets the animation type of the SfBadge. Animation is triggered when content is changed.

    Declaration
    public BadgeAnimationType AnimationType { get; set; }
    Property Value
    Type Description
    BadgeAnimationType

    A value of the enumeration. The default is None.

    Remarks

    When badge content is changed, badge animates to notify that there was a change.

    CustomShape

    Gets or sets the custom shape of the SfBadge. CustomShape used as background of badge only when Shape is Custom.

    Declaration
    public Geometry CustomShape { get; set; }
    Property Value
    Type Description
    System.Windows.Media.Geometry

    The default is null.

    Remarks

    A custom shape can be defined as required, when any of the build-in Shape is not sufficient.

    Examples

    Following example shows a badge with custom background shape.

    <Button Width="100"
            Height="50" 
            Content="Inbox">
       <syncfusion:SfBadge.Badge>
           <syncfusion:SfBadge CustomShape="M0,20L20,0 40,20 20,40z"
                              Content="99+" Shape="Custom"
                              Name="badge">
    
       &lt;/syncfusion:SfBadge>
    

    </syncfusion:SfBadge.Badge> </Button>

    Fill

    Gets or sets the Brush from predefined set of brushes that paints the interior area of the Shape.

    Declaration
    public BadgeFill Fill { get; set; }
    Property Value
    Type Description
    BadgeFill

    A value of the enumeration. The default is Accent.

    Remarks

    Use Background property to set custom fill color for badge shape.

    HorizontalAnchor

    Gets or sets the horizontal placement (inside, center or outside) of the SfBadge relative to its position when attaching a badge control to the visual element. For example, If HorizontalAlignment is Right and HorizontalAnchor is outside, then badge overlay is positioned to right side of the visual element based on horizontal alignment and placed outside the bounds of element based on horizontal anchor.

    Declaration
    public BadgeAnchor HorizontalAnchor { get; set; }
    Property Value
    Type Description
    BadgeAnchor

    A value of the enumeration. The default is Center.

    Remarks

    HorizontalAnchor decides whether the badge will be aligned inside, center or outside the element bounds horizontally. To perform precise placement use HorizontalAnchorPosition by setting HorizontalAnchor as Custom.

    HorizontalAnchorPosition

    Gets or sets the horizontal placement of SfBadge in numerical precision (0 to 1) when HorizontalAnchor is Custom.

    Declaration
    public double HorizontalAnchorPosition { get; set; }
    Property Value
    Type Description
    System.Double

    The default value is 0. This value can be any value equal to or between 0 and less 1.

    Remarks

    If HorizontalAlignment is Right and HorizontalAnchorPosition is 1, the badge overlay positioned right side of visual element and placed within the bounds of element based on Horizontal Anchor Position.

    Refer HorizontalAnchor to know more about placement.

    HorizontalPosition

    Gets or sets the horizontal alignment of the SfBadge in numerical precision (0 to 1) when attaching a badge control to the visual element. uses HorizontalAlignment to position the badge overlay when HorizontalPosition value is NaN.

    Declaration
    public double HorizontalPosition { get; set; }
    Property Value
    Type Description
    System.Double

    The default value is NaN. This value can be any value equal to or between 0 and less 1.

    Remarks

    The value 0 denotes HorizontalAlignment.Left and 1 denotes HorizontalAlignment.Right. The horizontal alignment of badge overlay calculated using width of vvisual element and horizontal position.

    Examples

    Following example shows changing of alignment using HorizontalPosition and VerticalPosition.

    <Button Width="100"
       Height="50" 
       Content="Inbox">
    <syncfusion:SfBadge.Badge>
       <syncfusion:SfBadge Content = "10"
                             x:Name="badge"/>
    </syncfusion:SfBadge.Badge>
     </Button>

    Shape

    Gets or sets the shape of the SfBadge.

    Declaration
    public BadgeShape Shape { get; set; }
    Property Value
    Type Description
    BadgeShape

    A value of the enumeration. The default is Oval.

    Remarks

    Badge background shape can be Ellipse, Oval, Rectangle or None. Custom background shape can be defined using CustomShape by setting Shape as Custom.

    Stroke

    Gets or sets the Brush that specifies how the Shape outline is painted.

    Declaration
    public Brush Stroke { get; set; }
    Property Value
    Type Description
    System.Windows.Media.Brush

    A Brush that specifies how the Shape outline is painted.

    StrokeThickness

    Gets or sets the width of the Shape stroke outline.

    Declaration
    public double StrokeThickness { get; set; }
    Property Value
    Type Description
    System.Double

    The width of the Shape outline, in pixels. The default value is 0.

    VerticalAnchor

    Gets or sets the vertical placement (inside, center or outside) of the SfBadge relative to its position when attaching a badge control to the visual element. For example, If VerticalAlignment is Top and VerticalAnchor is Outside, then badge overlay is positioned to top side of the visual element based on vertical alignment and placed outside the bounds of element based on vertical anchor.

    Declaration
    public BadgeAnchor VerticalAnchor { get; set; }
    Property Value
    Type Description
    BadgeAnchor

    A value of the enumeration. The default is Center.

    Remarks

    VerticalAnchor decides whether the badge will be aligned inside, center or outside the container bounds vertically. To perform precise placement use VerticalAnchorPosition by setting VerticalAnchor as Custom.

    VerticalAnchorPosition

    Gets or sets the vertical placement of SfBadge in numerical precision (0 to 1) when VerticalAnchor is Custom.

    Declaration
    public double VerticalAnchorPosition { get; set; }
    Property Value
    Type Description
    System.Double

    The default value is 0. This value can be any value equal to or between 0 and less 1.

    Remarks

    If VerticalAlignment is Top and VerticalAnchorPosition is 0, the badge overlay positioned top side of element and placed within the bounds of element based on Vertical Anchor Position.

    Refer VerticalAnchor to know more about placement.

    VerticalPosition

    Gets or sets the vertical alignment of the SfBadge in numerical precision (0 to 1) when attaching a badge control to the visual element. uses VerticalAlignment to position the badge overlay when VerticalPosition value is NaN.

    Declaration
    public double VerticalPosition { get; set; }
    Property Value
    Type Description
    System.Double

    The default value is NaN. This value can be any value equal to or between 0 and less 1.

    Remarks

    The value 0 denotes VerticalAlignment.Top and 1 denotes VerticalAlignment.Bottom. The vertical alignment of badge overlay calculated using height of the visual element and vertical position.

    Examples

    Following example shows changing of aligment using HorizontalPosition and VerticalPosition.

    <Button Width="100"
    Height="50" 
    Content="Inbox">
       <syncfusion:SfBadge.Badge>
           <syncfusion:SfBadge Shape="None"
                              HorizontalPosition="0.9"
                               VerticalPosition="0.8">
              <Ellipse Width="20" Height="20" Fill="LimeGreen"/>
           </syncfusion:SfBadge>
       </syncfusion:SfBadge.Badge>
    </Button>

    Methods

    GetBadge(DependencyObject)

    Gets a Badge that is attached to the Control.

    Declaration
    public static SfBadge GetBadge(DependencyObject dependencyObject)
    Parameters
    Type Name Description
    System.Windows.DependencyObject dependencyObject

    Represents the SfBadge control.

    Returns
    Type Description
    SfBadge

    Returns the SfBadge value.

    OnApplyTemplate()

    Declaration
    public override void OnApplyTemplate()

    OnContentChanged(Object, Object)

    Declaration
    protected override void OnContentChanged(object oldContent, object newContent)
    Parameters
    Type Name Description
    System.Object oldContent
    System.Object newContent

    OnPropertyChanged(DependencyPropertyChangedEventArgs)

    Declaration
    protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
    Parameters
    Type Name Description
    System.Windows.DependencyPropertyChangedEventArgs e

    SetBadge(DependencyObject, SfBadge)

    Sets the Badge to the control.

    Declaration
    public static void SetBadge(DependencyObject dependencyObject, SfBadge value)
    Parameters
    Type Name Description
    System.Windows.DependencyObject dependencyObject

    Represents the SfBadge control.

    SfBadge value

    Represents the SfBadge value.

    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved