'Declaration Public ReadOnly Property Location As ToolLocation
public ToolLocation Location {get;}
Possible tool locations include: Ribbon, Menu, QuickAccessToolbar, ApplicationMenu, ApplicationMenuFooterToolbar, ApplicationMenuRecentItems.
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