Class RibbonButton
Represents RibbonButton control.
Namespace: Syncfusion.Windows.Tools.Controls
Assembly: Syncfusion.Tools.Wpf.dll
Syntax
public class RibbonButton : ButtonBase, ICollapsable, IRibbonControl, IDisposable
Remarks
RibbonButton class represents a Ribbon button control.
Examples
This example shows how to create a RibbonButton in XAML.
<ribbon:RibbonButton SizeForm="Small" Label="Item1" SmallIcon="SampleImages/Document32.png"/>
This example shows how to create a RibbonButton in C#.
RibbonButton button = new RibbonButton();
button.Label = "Item";
Constructors
RibbonButton()
Initializes a new instance of the RibbonButton class.
Declaration
public RibbonButton()
Fields
CollapseLabelProperty
Get or Sets the Collapse Label of Ribbon Button. It is a dependency property.
Declaration
public static readonly DependencyProperty CollapseLabelProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
CornerRadiusProperty
Defines corner radius of button. This is a dependency property.
Declaration
public static readonly DependencyProperty CornerRadiusProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
IconStretchProperty
Identifies the IconStretch dependency property.
Declaration
public static readonly DependencyProperty IconStretchProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
Remarks
The identifier for the IconStretch dependency property.
IconTemplateProperty
Identifies the IconTemplate dependency property.
Declaration
public static readonly DependencyProperty IconTemplateProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
Remarks
The identifier for the IconTemplate dependency property.
IconTemplateSelectorProperty
Identifies the IconTemplateSelector dependency property.
Declaration
public static readonly DependencyProperty IconTemplateSelectorProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
Remarks
The identifier for the IconTemplateSelector dependency property.
IconTypeProperty
Identifies the IconType Property.
Declaration
public static readonly DependencyProperty IconTypeProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
IsLargeImageVisibleProperty
Identifies the large icon is set in the control.
Declaration
protected static readonly DependencyProperty IsLargeImageVisibleProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
IsMenuItemProperty
Used to know about this is MenuItem or not.
Declaration
public static readonly DependencyProperty IsMenuItemProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
IsMultiLineProperty
Identifies whether multiline is set to the Label property.
Declaration
protected static readonly DependencyProperty IsMultiLineProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
IsSelectedProperty
Defines when button is selected. This is a dependency property.
Declaration
public static readonly DependencyProperty IsSelectedProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
IsSmallImageVisibleProperty
Identifies the small icon is set in the control.
Declaration
protected static readonly DependencyProperty IsSmallImageVisibleProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
IsToggleProperty
Defines when button is toggle. This is a dependency property.
Declaration
public static readonly DependencyProperty IsToggleProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
LabelProperty
Defines button label. This is a dependency property.
Declaration
public static readonly DependencyProperty LabelProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
LargeIconProperty
Defines large button icon. This is a dependency property.
Declaration
public static readonly DependencyProperty LargeIconProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
MediumIconProperty
Identifies the MediumIcon dependency property.
Declaration
public static readonly DependencyProperty MediumIconProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
Remarks
The identifier for the MediumIcon dependency property.
SizeFormProperty
Defines size of the button. This is a dependency property.
Declaration
public static readonly DependencyProperty SizeFormProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
SmallIconProperty
Defines small button icon. This is a dependency property.
Declaration
public static readonly DependencyProperty SmallIconProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
SplitLabelIntoTwoLineProperty
Identifies the SplitLabelIntoTwoLine Property.
Declaration
protected static readonly DependencyProperty SplitLabelIntoTwoLineProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
VectorImageProperty
Identifies the VectorImage Property.
Declaration
protected static readonly DependencyProperty VectorImageProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
Properties
CollapseLabel
Gets or sets the collapse label.
Declaration
public string CollapseLabel { get; set; }
Property Value
Type | Description |
---|---|
System.String | The collapse label. |
CornerRadius
Gets or sets a value that represents the degree to which the corners of a RibbonButton are rounded.
Declaration
public CornerRadius CornerRadius { get; set; }
Property Value
Type | Description |
---|---|
System.Windows.CornerRadius | Type: CornerRadius The CornerRadius that describes the degree to which corners are rounded. This property has no default value. |
Remarks
Although the property name suggests that you can use only singular values, CornerRadius also supports non-uniform radii. Radius values that are too large are scaled so that they blend smoothly from corner to corner.
Examples
RibbonButton button = new RibbonButton();
button.Label = "Button";
button.CornerRadius = new CornerRadius(3);
See Also
IconStretch
Gets or sets to fills the Icon in allocated space
Declaration
public Stretch IconStretch { get; set; }
Property Value
Type |
---|
System.Windows.Media.Stretch |
IconTemplate
Gets or sets the template that used to display the icon of RibbonButton.
Declaration
public DataTemplate IconTemplate { get; set; }
Property Value
Type | Description |
---|---|
System.Windows.DataTemplate | The System.Windows.DataTemplate that is used to display a icon in RibbonButton. |
Remarks
IconTemplate inherits its parent DataContext. When icon template is defined, RibbonButton loads icon using template instead of SmallIcon, LargeIcon and MediumIcon properties or VectorImage. It loads icon in the following priority order,
Examples
The example below illustrates how to use IconTemplate.
<syncfusion:RibbonButton>
<syncfusion:RibbonButton.IconTemplate>
<DataTemplate x:Name="template">
<Grid >
<Image Width="26" Height="26" Source="/Resources/Paste32.png"/>
</Grid>
</DataTemplate>
</syncfusion:RibbonButton.IconTemplate>
</syncfusion:RibbonButton>
The new IconTemplate property used which has the features to customize the ribbon button template.
IconTemplateSelector
Gets or sets a System.Windows.Controls.DataTemplateSelector that determines the template to display icon in a RibbonButton based on SizeForm.
Declaration
public DataTemplateSelector IconTemplateSelector { get; set; }
Property Value
Type | Description |
---|---|
System.Windows.Controls.DataTemplateSelector | A custom System.Windows.Controls.DataTemplateSelector selector object that provides logic to choose a System.Windows.DataTemplate to be returned. The default is null. |
Remarks
The RibbonButton exposes IconTemplateSelector, IconTemplate, LargeIcon, SmallIcon, MediumIcon and VectorImage properties for setting the icon. It loads icon in the following priority order,
See Also
IconType
Declaration
public IconType IconType { get; set; }
Property Value
Type |
---|
IconType |
IsLargeImageVisible
Gets or sets a value indicating whether this instance large image is set.
Declaration
public bool IsLargeImageVisible { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
IsMenuItem
Gets or sets a value indicating whether this instance is menu item.
Declaration
public bool IsMenuItem { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
IsMultiLine
Gets and Sets a value indicating whether Label text can be wrraped to next line.
Declaration
public bool IsMultiLine { get; set; }
Property Value
Type |
---|
System.Boolean |
IsSelected
Gets or sets a value indicating whether this instance is selected. RibbonButton is selected.
Declaration
public bool IsSelected { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | Type: System.Boolean true if the RibbonButton is selected; false if the RibbonButton is not selected. The default is false. |
Examples
RibbonButton button = new RibbonButton();
button.Label = "Button";
button.IsToggle = true;
button.IsSelected = true;
See Also
IsSmallImageVisible
Gets or sets a value indicating whether this instance small image is set.
Declaration
public bool IsSmallImageVisible { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
IsToggle
Gets or sets a value indicating whether the RibbonButton is toggle button.
Declaration
public bool IsToggle { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | Type: System.Boolean true if the RibbonButton is toggle; false if the RibbonButton is not toggle. The default is false. |
Examples
RibbonButton button = new RibbonButton();
button.Label = "Button";
button.IsToggle = true;
button.IsSelected = true;
See Also
Label
Gets or sets the text that labels the RibbonButton.
Declaration
public string Label { get; set; }
Property Value
Type | Description |
---|---|
System.String | Type: System.String Text that labels the RibbonButton. The default is empty string. |
Examples
RibbonButton button = new RibbonButton();
button.Label = "Button";
button.CornerRadius = new CornerRadius(3);
See Also
LargeIcon
Gets or sets the large icon that appears in a RibbonButton.
Declaration
public ImageSource LargeIcon { get; set; }
Property Value
Type |
---|
System.Windows.Media.ImageSource |
Remarks
When IconTemplate property is defined, RibbonButton loads icon using IconTemplate instead of LargeIcon.
Examples
// Create the image element.
RibbonButton button = new RibbonButton();
// Create source.
BitmapImage bimage = new BitmapImage();
// BitmapImage.UriSource must be in a BeginInit/EndInit block.
bimage.BeginInit();
bimage.UriSource = new Uri(@"/sampleImages/sample.jpg",UriKind.RelativeOrAbsolute);
bimage.EndInit();
// Set the image source.
button.LargeIcon = bimage;
See Also
MediumIcon
Gets or sets the medium icon that appears in the control during the simplified mode.
Declaration
public ImageSource MediumIcon { get; set; }
Property Value
Type |
---|
System.Windows.Media.ImageSource |
Remarks
When IconTemplate is defined, RibbonButton loads icon using IconTemplate instead of MediumIcon.
Examples
// Create the image element.
RibbonButton button = new RibbonButton();
// Create source.
BitmapImage bimage = new BitmapImage();
// BitmapImage.UriSource must be in a BeginInit/EndInit block.
bimage.BeginInit();
bimage.UriSource = new Uri(@"/sampleImages/sample.jpg",UriKind.RelativeOrAbsolute);
bimage.EndInit();
// Set the image source.
button.MediumIcon = bimage;
See Also
SizeForm
Gets or sets the size form.RibbonButton size.
Declaration
public SizeForm SizeForm { get; set; }
Property Value
Type | Description |
---|---|
SizeForm | Type: SizeForm Enumeration that specifies type of the RibbonButton size. |
Remarks
When Icon template is defined, RibbonButton loads icon using template depends on the size form (ExtraSmall, Small, Large).
Examples
RibbonButton button = new RibbonButton();
button.Label = "Button";
button.SizeForm = SizeForm.Large;
See Also
SmallIcon
Gets or sets the small icon that appears in a RibbonButton.
Declaration
public ImageSource SmallIcon { get; set; }
Property Value
Type |
---|
System.Windows.Media.ImageSource |
Remarks
When IconTemplate property is defined, RibbonButton loads icon using IconTemplate instead of SmallIcon.
Examples
// Create the image element.
RibbonButton button = new RibbonButton();
// Create source.
BitmapImage bimage = new BitmapImage();
// BitmapImage.UriSource must be in a BeginInit/EndInit block.
bimage.BeginInit();
bimage.UriSource = new Uri(@"/sampleImages/sample.jpg",UriKind.RelativeOrAbsolute);
bimage.EndInit();
// Set the image source.
button.SmallIcon = bimage;
See Also
SplitLabelIntoTwoLine
Gets or sets a value indicating whether [split label into two line].
Declaration
public bool SplitLabelIntoTwoLine { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
VectorImage
Gets or sets a vector image that appears in a RibbonButton.
Declaration
public ObservableCollection<Path> VectorImage { get; set; }
Property Value
Type |
---|
System.Collections.ObjectModel.ObservableCollection<System.Windows.Shapes.Path> |
Remarks
When IconTemplate is defined, RibbonButton loads icon using IconTemplate instead of VectorImage.
Methods
CoerceOnIsMultiline(Object)
Coerces the on is multiline.
Declaration
protected virtual object CoerceOnIsMultiline(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The value. |
Returns
Type |
---|
System.Object |
CoerceOnIsMultiline(DependencyObject, Object)
Coerces the on is multiline.
Declaration
public static object CoerceOnIsMultiline(DependencyObject d, object baseValue)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyObject | d | The d. |
System.Object | baseValue | The base value. |
Returns
Type |
---|
System.Object |
CoerceOnLabel(Object)
Coerces the on label.
Declaration
protected virtual object CoerceOnLabel(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The value. |
Returns
Type |
---|
System.Object |
CoerceOnLabel(DependencyObject, Object)
Coerces the on label.
Declaration
public static object CoerceOnLabel(DependencyObject d, object baseValue)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyObject | d | The d. |
System.Object | baseValue | The base value. |
Returns
Type |
---|
System.Object |
Dispose()
Dispose all used objects
Declaration
public void Dispose()
LockEvents()
Locks events.
Declaration
protected void LockEvents()
OnApplyTemplate()
When overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate.
Declaration
public override void OnApplyTemplate()
OnClick()
Raises the System.Windows.Controls.Primitives.ButtonBase.Click routed event.
Declaration
protected override void OnClick()
OnCreateAutomationPeer()
Creates AutomationPeer for ribbon button.
Declaration
protected override AutomationPeer OnCreateAutomationPeer()
Returns
Type | Description |
---|---|
System.Windows.Automation.Peers.AutomationPeer | An appropriate RibbonButtonAutomationPeer for this control as part of the WPF infrastructure. |
OnIsMultiLineChanged(DependencyPropertyChangedEventArgs)
Raises the IsMultiLineChanged event.
Declaration
protected virtual void OnIsMultiLineChanged(DependencyPropertyChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyPropertyChangedEventArgs | e | The System.Windows.DependencyPropertyChangedEventArgs instance containing the event data. |
OnIsSelectedChanged(DependencyPropertyChangedEventArgs)
Updates property value cache and raises IsSelectedChanged event.
Declaration
protected virtual void OnIsSelectedChanged(DependencyPropertyChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyPropertyChangedEventArgs | e | Property changes details, such as old value and new value. |
OnIsToggleChanged(DependencyPropertyChangedEventArgs)
Updates property value cache and raises IsToggleChanged event.
Declaration
protected virtual void OnIsToggleChanged(DependencyPropertyChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyPropertyChangedEventArgs | e | Property changes details, such as old value and new value. |
OnLabelChanged(DependencyPropertyChangedEventArgs)
Updates property value cache and raises LabelChanged event.
Declaration
protected virtual void OnLabelChanged(DependencyPropertyChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyPropertyChangedEventArgs | e | Property changes details, such as old value and new value. |
OnLargeIconChanged(DependencyPropertyChangedEventArgs)
Updates property value cache and raises LargeIconChanged event.
Declaration
protected virtual void OnLargeIconChanged(DependencyPropertyChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyPropertyChangedEventArgs | e | Property changes details, such as old value and new value. |
OnMouseRightButtonUp(MouseButtonEventArgs)
Invoked when an unhandled System.Windows.UIElement.MouseRightButtonUprouted event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.
Declaration
protected override void OnMouseRightButtonUp(MouseButtonEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Input.MouseButtonEventArgs | e | The System.Windows.Input.MouseButtonEventArgs that contains the event data. The event data reports that the right mouse button was released. |
OnSizeFormChanged(DependencyPropertyChangedEventArgs)
Updates property value cache and raises SizeFormChanged event.
Declaration
protected virtual void OnSizeFormChanged(DependencyPropertyChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyPropertyChangedEventArgs | e | Property change details, such as old value and new value. |
OnSmallIconChanged(DependencyPropertyChangedEventArgs)
Updates property value cache and raises SmallIconChanged event.
Declaration
protected virtual void OnSmallIconChanged(DependencyPropertyChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyPropertyChangedEventArgs | e | Property changes details, such as old value and new value. |
OnSplitLabelIntoTwoLineChanged(DependencyPropertyChangedEventArgs)
Raises the IsMultiLineChanged event.
Declaration
protected virtual void OnSplitLabelIntoTwoLineChanged(DependencyPropertyChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyPropertyChangedEventArgs | e | The System.Windows.DependencyPropertyChangedEventArgs instance containing the event data. |
OnStylusSystemGesture(StylusSystemGestureEventArgs)
Returns class-specific AutomationPeer implementations for the Windows Presentation Foundation infrastructure.
Declaration
protected override void OnStylusSystemGesture(StylusSystemGestureEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Input.StylusSystemGestureEventArgs | e |
OnTouchUp(TouchEventArgs)
Provides class handling for the PreviewTouchUp routed event that occurs when a touch is released inside this element.
Declaration
protected override void OnTouchUp(TouchEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Input.TouchEventArgs | e | The event data |
UnLockEvents()
Locks events.
Declaration
protected void UnLockEvents()
Events
IsMultiLineChanged
Occurs when [is multi line changed].
Declaration
public event PropertyChangedCallback IsMultiLineChanged
Event Type
Type |
---|
System.Windows.PropertyChangedCallback |
IsSelectedChanged
Event that is raised when IsSelected property is changed.
Declaration
public event PropertyChangedCallback IsSelectedChanged
Event Type
Type |
---|
System.Windows.PropertyChangedCallback |
IsToggleChanged
Event that is raised when IsToggle property is changed.
Declaration
public event PropertyChangedCallback IsToggleChanged
Event Type
Type |
---|
System.Windows.PropertyChangedCallback |
LabelChanged
Event that is raised when Label property is changed.
Declaration
public event PropertyChangedCallback LabelChanged
Event Type
Type |
---|
System.Windows.PropertyChangedCallback |
LargeIconChanged
Event that is raised when LargeIcon property is changed.
Declaration
public event PropertyChangedCallback LargeIconChanged
Event Type
Type |
---|
System.Windows.PropertyChangedCallback |
SizeFormChanged
Event that is raised when SizeForm property is changed.
Declaration
public event PropertyChangedCallback SizeFormChanged
Event Type
Type |
---|
System.Windows.PropertyChangedCallback |
SmallIconChanged
Event that is raised when SmallIcon property is changed.
Declaration
public event PropertyChangedCallback SmallIconChanged
Event Type
Type |
---|
System.Windows.PropertyChangedCallback |
SplitLabelIntoTwoLineChanged
Occurs when [split label into two line changed].
Declaration
public event PropertyChangedCallback SplitLabelIntoTwoLineChanged
Event Type
Type |
---|
System.Windows.PropertyChangedCallback |
Explicit Interface Implementations
IRibbonControl.get_ToolTip()
Declaration
object IRibbonControl.get_ToolTip()
Returns
Type |
---|
System.Object |