'Declaration Public Event Cloned As EventHandler(Of ToolClonedEventArgs)
public event EventHandler<ToolClonedEventArgs> Cloned
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.
Property | Description |
---|---|
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. |
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.
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; }
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