Version

RadioButtonTool Class

A tool that represents 3 user selectable states: Checked, Unchecked and Indeterminate. Since the tool is derived from the WPF RadioButton element, the usage semantics are the same as a WPF RadioButton.
Syntax
'Declaration
 
Public Class RadioButtonTool 
   Inherits System.Windows.Controls.RadioButton
public class RadioButtonTool : System.Windows.Controls.RadioButton 
Remarks

The RadioButtonTool exposes a GroupName property that allows multiple RadioButtonTools to toggle their states as part of a mutually exclusive group.

Note: The ToggleButtonTool supports the same 3 user selectable states but is designed to operate alone - i.e., it does not expose a GroupName property to coordinate its state with other ToggleButtonTools.

Example
RadioButtonTool Properties

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

Private Sub addRadioButtonToolProperties() 
    If xamRibbon.Tabs.Count < 1 Then 
        Return 
    End If 
    Dim igrTabItem As RibbonTabItem = xamRibbon.Tabs(0) 
    Dim radioButtonToolGroup As RibbonGroup = getRibbonGroup(igrTabItem, "RadioButtonToolProperties") 
    
    'Create RadioButtonTool 
    Dim radioButtonTool As New RadioButtonTool() 
    radioButtonTool.Caption = "RadioButton Tool" 
    radioButtonTool.Id = "RadioButton1" 
    radioButtonTool.KeyTip = "RB1" 
    radioButtonTool.LargeImage = getImageSource("/images/icons/Ribbon/Paste_32x32.png") 
    radioButtonTool.SmallImage = getImageSource("/images/icons/Ribbon/Paste_16x16.png") 
    radioButtonTool.IsChecked = True 
    
    radioButtonToolGroup.Items.Add(radioButtonTool) 
    
    AddHandler radioButtonTool.Click, AddressOf radioButtonTool_Click 
    AddHandler radioButtonTool.Cloned, AddressOf radioButtonTool_Cloned 
    AddHandler radioButtonTool.CloneDiscarded, AddressOf radioButtonTool_CloneDiscarded 
End Sub 

'Event Handlers 
Private Sub radioButtonTool_CloneDiscarded(ByVal sender As Object, ByVal e As Infragistics.Windows.Ribbon.Events.ToolCloneDiscardedEventArgs) 
    Me.mListBox.Items.Add("" & Chr(10) & "RadioButtonTool " + getSendername(sender) + " is cloned discarded!") 
    mListBox.ScrollIntoView(mListBox.Items(mListBox.Items.Count - 1)) 
End Sub 

Private Sub radioButtonTool_Cloned(ByVal sender As Object, ByVal e As Infragistics.Windows.Ribbon.Events.ToolClonedEventArgs) 
    Me.mListBox.Items.Add("" & Chr(10) & "RadioButtonTool " + getSendername(sender) + " is cloned!") 
    mListBox.ScrollIntoView(mListBox.Items(mListBox.Items.Count - 1)) 
End Sub 

Private Sub radioButtonTool_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) 
    Me.mListBox.Items.Add("" & Chr(10) & "RadioButtonTool " + getSendername(sender) + " is clicked!") 
    mListBox.ScrollIntoView(mListBox.Items(mListBox.Items.Count - 1)) 
End Sub 

'Print RadioButtonTool properties 
Private Function getSendername(ByVal sender As Object) As String 
    Dim result As String = "unknown" 
    
    If TypeOf sender Is RadioButtonTool Then 
        Dim rbtool As RadioButtonTool = TryCast(sender, RadioButtonTool) 
        result = "RadioButtonTool" + ":" + rbtool.Caption + "location:" + rbtool.Location.ToString() 
        result += "" & Chr(10) & "IsActine=" + rbtool.IsActive.ToString() + ",IsOnQat=" + rbtool.IsOnQat.ToString() 
        result += "" & Chr(10) & "HaImage=" + rbtool.HasImage.ToString() + ",IsQatCommonTool=" + rbtool.IsQatCommonTool.ToString() 
        result += "" & Chr(10) & "SizingMode=" + rbtool.SizingMode.ToString() + ",KeyTip=" + rbtool.KeyTip 
        result += "" & Chr(10) & "HasCaption=" + rbtool.HasCaption.ToString() + ",Id=" + rbtool.Id 
        result += "" & Chr(10) & "IsChecked=" + rbtool.IsChecked.ToString() 
        result += "" & Chr(10) & "LargeImage=" + rbtool.LargeImage.ToString() 
        result += "" & Chr(10) & "SmallImage=" + rbtool.SmallImage.ToString() 
    End If 
    
    Return result 
End Function 

'Create RibbonGroup 
Private Function getRibbonGroup(ByVal igTabItem As RibbonTabItem, ByVal ribbonGroupCaption As String) As RibbonGroup 
    Dim ribbonGroup As New RibbonGroup() 
    ribbonGroup.Caption = ribbonGroupCaption 
    Dim toolHorizontalWrapPanel As New ToolHorizontalWrapPanel() 
    ribbonGroup.Items.Add(toolHorizontalWrapPanel) 
    igTabItem.RibbonGroups.Add(ribbonGroup) 
    Return ribbonGroup 
End Function
private void addRadioButtonToolProperties()
{
	if (xamRibbon.Tabs.Count < 1) { return; }
	RibbonTabItem igrTabItem = xamRibbon.Tabs[0];
	RibbonGroup radioButtonToolGroup = getRibbonGroup(igrTabItem, "RadioButtonToolProperties");

	//Create RadioButtonTool
	RadioButtonTool radioButtonTool = new RadioButtonTool();
	radioButtonTool.Caption = "RadioButton Tool";
	radioButtonTool.Id = "RadioButton1";
	radioButtonTool.KeyTip = "RB1";
	radioButtonTool.LargeImage = getImageSource("/images/icons/Ribbon/Paste_32x32.png");
	radioButtonTool.SmallImage = getImageSource("/images/icons/Ribbon/Paste_16x16.png");
	radioButtonTool.IsChecked = true;

	radioButtonToolGroup.Items.Add(radioButtonTool);

	radioButtonTool.Click += new RoutedEventHandler(radioButtonTool_Click);
	radioButtonTool.Cloned += new EventHandler<Infragistics.Windows.Ribbon.Events.ToolClonedEventArgs>(radioButtonTool_Cloned);
	radioButtonTool.CloneDiscarded += new EventHandler<Infragistics.Windows.Ribbon.Events.ToolCloneDiscardedEventArgs>(radioButtonTool_CloneDiscarded);
}

//Event Handlers
void radioButtonTool_CloneDiscarded(object sender, Infragistics.Windows.Ribbon.Events.ToolCloneDiscardedEventArgs e)
{
	this.mListBox.Items.Add("\nRadioButtonTool " + getSendername(sender) + " is cloned discarded!");
	mListBox.ScrollIntoView(mListBox.Items[mListBox.Items.Count - 1]);
}

void radioButtonTool_Cloned(object sender, Infragistics.Windows.Ribbon.Events.ToolClonedEventArgs e)
{
	this.mListBox.Items.Add("\nRadioButtonTool " + getSendername(sender) + " is cloned!");
	mListBox.ScrollIntoView(mListBox.Items[mListBox.Items.Count - 1]);
}

void radioButtonTool_Click(object sender, RoutedEventArgs e)
{
	this.mListBox.Items.Add("\nRadioButtonTool " + getSendername(sender) + " is clicked!");
	mListBox.ScrollIntoView(mListBox.Items[mListBox.Items.Count - 1]);
}

//Print RadioButtonTool properties
private string getSendername(object sender)
{
    string result = "unknown";

	if (sender is RadioButtonTool)
	{
		RadioButtonTool rbtool = sender as RadioButtonTool;
		result = "RadioButtonTool" + ":" + rbtool.Caption + "location:" + rbtool.Location.ToString();
		result += "\nIsActine=" + rbtool.IsActive.ToString() + ",IsOnQat=" + rbtool.IsOnQat.ToString();
		result += "\nHaImage=" + rbtool.HasImage.ToString() + ",IsQatCommonTool=" + rbtool.IsQatCommonTool.ToString();
		result += "\nSizingMode=" + rbtool.SizingMode.ToString() + ",KeyTip=" + rbtool.KeyTip;
		result += "\nHasCaption=" + rbtool.HasCaption.ToString() + ",Id=" + rbtool.Id;
		result += "\nIsChecked=" + rbtool.IsChecked.ToString();
		result += "\nLargeImage=" + rbtool.LargeImage.ToString();
		result += "\nSmallImage=" + rbtool.SmallImage.ToString();
	}
			
	return result;
}

//Create RibbonGroup
private RibbonGroup getRibbonGroup(RibbonTabItem igTabItem, string ribbonGroupCaption)
{
	RibbonGroup ribbonGroup = new RibbonGroup();
	ribbonGroup.Caption = ribbonGroupCaption;
	ToolHorizontalWrapPanel toolHorizontalWrapPanel = new ToolHorizontalWrapPanel();
	ribbonGroup.Items.Add(toolHorizontalWrapPanel);
	igTabItem.RibbonGroups.Add(ribbonGroup);
	return ribbonGroup;
}
<!--RadioButtonTool-->
<igRibbon:RadioButtonTool Name="boldTool" Id="boldToolId" KeyTip="TB1"
    
LargeImage="Images\icons\Ribbon\Bold.png" 
    
SmallImage="Images\icons\Ribbon\Bold.png" 
    
Click="boldTool_Click" IsChecked="True"
    
igRibbon:RibbonGroup.MaximumSize="ImageAndTextLarge"
    
igRibbon:RibbonGroup.MinimumSize="ImageOnly" />
<!--RadioButtonTool-end-->


private void boldTool_Click(object sender, RoutedEventArgs e)
{
    MessageBox.Show("boldTool is clicked!");
}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also