Version

Cloned Event (ToggleButtonTool)

Occurs after a tool has been cloned.
Syntax
'Declaration
 
Public Event Cloned As EventHandler(Of ToolClonedEventArgs)
public event EventHandler<ToolClonedEventArgs> Cloned
Event Data

The event handler receives an argument of type ToolClonedEventArgs containing data related to this event. The following ToolClonedEventArgs properties provide information specific to this event.

PropertyDescription
ClonedTool Returns the cloned tool instance (read-only)
EventHandlersAttached Returns a boolean indicating if the event handlers for routed events of the OriginalTool were associated with the same events for the ClonedTool
Handled (Inherited from System.Windows.RoutedEventArgs)Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route.
OriginalSource (Inherited from System.Windows.RoutedEventArgs)Gets the original reporting source as determined by pure hit testing, before any possible System.Windows.RoutedEventArgs.Source adjustment by a parent class.
OriginalTool Returns the cloned tool instance (read-only)
RoutedEvent (Inherited from System.Windows.RoutedEventArgs)Gets or sets the System.Windows.RoutedEventArgs.RoutedEvent associated with this System.Windows.RoutedEventArgs instance.
Source (Inherited from System.Windows.RoutedEventArgs)Gets or sets a reference to the object that raised the event.
Remarks

Fired when a tool is cloned to enable its placement in an additional location in the XamRibbon. For example, when a tool is added to the QuickAccessToolbar, the XamRibbon clones the instance of the tool that appears on the Ribbon and places the cloned instance on the QAT. This event is fired after the cloning takes place and is a convenient point hook up event listeners for events on the cloned tool.

Example
ToggleButtonTool Properties Sample

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 xamRibbon As XamRibbon
Private mListBox As ListBox
Private Sub addToggleButtonToolProperties()
'Code to Create XamRibbon object..

    If xamRibbon.Tabs.Count < 1 Then
        Return
    End If
    Dim igrTabItem As RibbonTabItem = xamRibbon.Tabs(0)
    'add RibbonGroup
    Dim toggleButtonToolGroup As RibbonGroup = getRibbonGroup(igrTabItem, "ToggleButtonToolProperties")
    'Add ToggleButtonTool
    Dim toggleBtnTool As New ToggleButtonTool()
    toggleBtnTool.Caption = "Toggle Button"
    toggleBtnTool.Id = "ToggleButton1"
    toggleBtnTool.KeyTip = "TG1"
    toggleBtnTool.LargeImage = getImageSource("/images/icons/Ribbon/New_Large.png")
    toggleBtnTool.SmallImage = getImageSource("/images/icons/Ribbon/Open_Large.png")
    toggleBtnTool.IsChecked = True
    AddHandler toggleBtnTool.Click, AddressOf toggleBtnTool_Click
    AddHandler toggleBtnTool.Cloned, AddressOf toggleBtnTool_Cloned
    AddHandler toggleBtnTool.CloneDiscarded, AddressOf toggleBtnTool_CloneDiscarded
    toggleButtonToolGroup.Items.Add(toggleBtnTool)
End Sub

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

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

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


Private Function getSendername(ByVal sender As Object) As String
    Dim result As String = "unknown"
   
    If TypeOf sender Is ToggleButtonTool Then
        Dim tbtool As ToggleButtonTool = TryCast(sender, ToggleButtonTool)
        result = "ToggleButtonTool" + ":" + tbtool.Caption + "location:" + tbtool.Location.ToString()
        result += "" & Chr(10) & "IsActine=" + tbtool.IsActive.ToString() + ",IsOnQat=" + tbtool.IsOnQat.ToString()
        result += "" & Chr(10) & "HaImage=" + tbtool.HasImage.ToString() + ",IsQatCommonTool=" + tbtool.IsQatCommonTool.ToString()
        result += "" & Chr(10) & "SizingMode=" + tbtool.SizingMode.ToString() + ",KeyTip=" + tbtool.KeyTip
        result += "" & Chr(10) & "HasCaption=" + tbtool.HasCaption.ToString() + ",Id=" + tbtool.Id
        result += "" & Chr(10) & "IsChecked=" + tbtool.IsChecked.ToString()
        result += "" & Chr(10) & "LargeImage=" + tbtool.LargeImage.ToString()
        result += "" & Chr(10) & "SmallImage=" + tbtool.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
<!--ToggleButtonTol-->
<igRibbon:ToggleButtonTool Name="boldTool" Id="boldToolId" KeyTip="TB1"
    
LargeImage="Images\icons\Ribbon\Bold.png" 
    
SmallImage="Images\icons\Ribbon\Bold.png" 
    
Click="boldTool_Click"
    
igRibbon:RibbonGroup.MaximumSize="ImageAndTextLarge"
    
igRibbon:RibbonGroup.MinimumSize="ImageOnly" />
<!--ToggleButtonTol-end-->


private void boldTool_Click(object sender, RoutedEventArgs e)
{
    MessageBox.Show("boldTool is clicked!");
}
XamRibbon xamRibbon;
//Code to Create XamRibbon object..
ListBox mListBox;

private void addToggleButtonToolProperties()
{
	if (xamRibbon.Tabs.Count < 1) { return; }
	RibbonTabItem igrTabItem = xamRibbon.Tabs[0];
	//add RibbonGroup
	RibbonGroup toggleButtonToolGroup = getRibbonGroup(igrTabItem, "ToggleButtonToolProperties");
	//Add ToggleButtonTool
	ToggleButtonTool toggleBtnTool = new ToggleButtonTool();
	toggleBtnTool.Caption = "Toggle Button";
	toggleBtnTool.Id = "ToggleButton1";
	toggleBtnTool.KeyTip = "TG1";
	toggleBtnTool.LargeImage = getImageSource("/images/icons/Ribbon/New_Large.png");
	toggleBtnTool.SmallImage = getImageSource("/images/icons/Ribbon/Open_Large.png");
	toggleBtnTool.IsChecked = true;
	toggleBtnTool.Click += new RoutedEventHandler(toggleBtnTool_Click);
	toggleBtnTool.Cloned += new EventHandler<Infragistics.Windows.Ribbon.Events.ToolClonedEventArgs>(toggleBtnTool_Cloned);
	toggleBtnTool.CloneDiscarded += new EventHandler<Infragistics.Windows.Ribbon.Events.ToolCloneDiscardedEventArgs>(toggleBtnTool_CloneDiscarded);
	toggleButtonToolGroup.Items.Add(toggleBtnTool);
}

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

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

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


 private string getSendername(object sender)
{
    string result = "unknown";

    if (sender is ToggleButtonTool)
    {
        ToggleButtonTool tbtool = sender as ToggleButtonTool;
        result = "ToggleButtonTool" + ":" + tbtool.Caption + "location:" + tbtool.Location.ToString();
        result += "\nIsActine=" + tbtool.IsActive.ToString() + ",IsOnQat=" + tbtool.IsOnQat.ToString();
        result += "\nHaImage=" + tbtool.HasImage.ToString() + ",IsQatCommonTool=" + tbtool.IsQatCommonTool.ToString();
        result += "\nSizingMode=" + tbtool.SizingMode.ToString() + ",KeyTip=" + tbtool.KeyTip;
        result += "\nHasCaption=" + tbtool.HasCaption.ToString() + ",Id=" + tbtool.Id;
        result += "\nIsChecked=" + tbtool.IsChecked.ToString();
        result += "\nLargeImage=" + tbtool.LargeImage.ToString();
        result += "\nSmallImage=" + tbtool.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;
}
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