Exception | Description |
---|---|
System.ArgumentException | The value assigned has more than 3 characters. |
Key tips are displayed when the ribbon is showing and the Alt key is pressed.
Note:
If the key tip for the item conflicts with another item in the same container, this key tip may be changed.
Private xamRibbon As XamRibbon Private Sub addButtonToolProperties() 'Code to Create XamRibbon object.. ListBox mListBox; If xamRibbon.Tabs.Count < 1 Then Return End If Dim igrTabItem As RibbonTabItem = xamRibbon.Tabs(0) 'add RibbonGroup Dim buttonToolGroup As RibbonGroup = getRibbonGroup(igrTabItem, "ButtonToolProperties") 'add ButtonTool Dim btnTool As ButtonTool = addButtonToolToRibbonGroup(buttonToolGroup, "buttonToolPtoperties", "btnToolProperties", "/images/icons/Ribbon/New_Large.png") Dim btnToolbuttonToolProperties As ButtonTool = addButtonToolToRibbonGroup(buttonToolGroup, "buttonToolProperties", "btnToolProperties", "/images/icons/Ribbon/EditCut.png") 'ButtnTool Properties btnTool.Id = "btnToolProperties" btnTool.KeyTip = "PR1" btnTool.SmallImage = getImageSource("/images/icons/Ribbon/New_Large.png") 'ButtonTool Events AddHandler btnTool.Click, AddressOf btnTool_Click AddHandler btnTool.Cloned, AddressOf btnTool_Cloned AddHandler btnTool.CloneDiscarded, AddressOf btnTool_CloneDiscarded End Sub 'Event Handlers Private Sub btnTool_CloneDiscarded(ByVal sender As Object, ByVal e As Infragistics.Windows.Ribbon.Events.ToolCloneDiscardedEventArgs) Me.mListBox.Items.Add("" & Chr(10) & "ButtonTool " + getSendername(sender) + " is cloned discarded!") mListBox.ScrollIntoView(mListBox.Items(mListBox.Items.Count - 1)) End Sub Private Sub btnTool_Cloned(ByVal sender As Object, ByVal e As Infragistics.Windows.Ribbon.Events.ToolClonedEventArgs) Me.mListBox.Items.Add("" & Chr(10) & "ButtonTool " + getSendername(sender) + " is cloned!") mListBox.ScrollIntoView(mListBox.Items(mListBox.Items.Count - 1)) End Sub Private Sub btnTool_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) Me.mListBox.Items.Add("" & Chr(10) & "ButtonTool " + getSendername(sender) + " is clicked!") mListBox.ScrollIntoView(mListBox.Items(mListBox.Items.Count - 1)) End Sub Private Function addButtonToolToRibbonGroup(ByVal igRibbongroup As RibbonGroup, ByVal caption As String, ByVal tagString As String, ByVal imageUriString As String) As ButtonTool Dim btnTool As ButtonTool = getButtonTool(caption, tagString, imageUriString) igRibbongroup.Items.Add(btnTool) Return btnTool End Function 'Get ButtonTool properties Private Function getSendername(ByVal sender As Object) As String Dim result As String = "unknown" If TypeOf sender Is ButtonTool Then Dim btool As ButtonTool = TryCast(sender, ButtonTool) result = "ButtonTool" + ":" + btool.Caption + " location:" + btool.Location.ToString() result += "" & Chr(10) & "IsActine=" + btool.IsActive.ToString() + ",IsOnQat=" + btool.IsOnQat.ToString() result += "" & Chr(10) & "HaImage=" + btool.HasImage.ToString() + ",IsQatCommonTool=" + btool.IsQatCommonTool.ToString() result += "" & Chr(10) & "SizingMode=" + btool.SizingMode.ToString() + ",KeyTip=" + btool.KeyTip result += "" & Chr(10) & "HasCaption=" + btool.HasCaption.ToString() + ",Id=" + btool.Id result += "" & Chr(10) & "LargeImage=" + btool.LargeImage.ToString() result += "" & Chr(10) & "SmallImage=" + btool.SmallImage.ToString() End If Return result End Function 'Get Image Source Private Function getImageSource(ByVal uriString As String) As BitmapImage Dim bmpImage As New BitmapImage() bmpImage.BeginInit() bmpImage.UriSource = New Uri(uriString, UriKind.RelativeOrAbsolute) bmpImage.EndInit() Return bmpImage End Function 'Add ButtonTool to RIbbonGroup Private Function addButtonToolToRibbonGroup(ByVal igRibbongroup As RibbonGroup, ByVal caption As String, ByVal tagString As String, ByVal imageUriString As String) As ButtonTool Dim btnTool As ButtonTool = getButtonTool(caption, tagString, imageUriString) igRibbongroup.Items.Add(btnTool) Return btnTool 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
XamRibbon xamRibbon; //Code to Create XamRibbon object.. ListBox mListBox; private void addButtonToolProperties() { if (xamRibbon.Tabs.Count < 1) { return; } RibbonTabItem igrTabItem = xamRibbon.Tabs[0]; //add RibbonGroup RibbonGroup buttonToolGroup = getRibbonGroup(igrTabItem, "ButtonToolProperties"); //add ButtonTool ButtonTool btnTool = addButtonToolToRibbonGroup(buttonToolGroup, "buttonToolPtoperties", "btnToolProperties", "/images/icons/Ribbon/New_Large.png"); ButtonTool btnToolbuttonToolProperties = addButtonToolToRibbonGroup(buttonToolGroup, "buttonToolProperties", "btnToolProperties", "/images/icons/Ribbon/EditCut.png"); //ButtnTool Properties btnTool.Id = "btnToolProperties"; btnTool.KeyTip = "PR1"; btnTool.SmallImage = getImageSource("/images/icons/Ribbon/New_Large.png"); //ButtonTool Events btnTool.Click += new RoutedEventHandler(btnTool_Click); btnTool.Cloned += new EventHandler<Infragistics.Windows.Ribbon.Events.ToolClonedEventArgs>(btnTool_Cloned); btnTool.CloneDiscarded += new EventHandler<Infragistics.Windows.Ribbon.Events.ToolCloneDiscardedEventArgs>(btnTool_CloneDiscarded); } //Event Handlers void btnTool_CloneDiscarded(object sender, Infragistics.Windows.Ribbon.Events.ToolCloneDiscardedEventArgs e) { this.mListBox.Items.Add("\nButtonTool " + getSendername(sender) + " is cloned discarded!"); mListBox.ScrollIntoView(mListBox.Items[mListBox.Items.Count - 1]); } void btnTool_Cloned(object sender, Infragistics.Windows.Ribbon.Events.ToolClonedEventArgs e) { this.mListBox.Items.Add("\nButtonTool " + getSendername(sender) + " is cloned!"); mListBox.ScrollIntoView(mListBox.Items[mListBox.Items.Count - 1]); } void btnTool_Click(object sender, RoutedEventArgs e) { this.mListBox.Items.Add("\nButtonTool " + getSendername(sender) + " is clicked!"); mListBox.ScrollIntoView(mListBox.Items[mListBox.Items.Count - 1]); } private ButtonTool addButtonToolToRibbonGroup(RibbonGroup igRibbongroup, string caption, string tagString, string imageUriString) { ButtonTool btnTool = getButtonTool(caption, tagString, imageUriString); igRibbongroup.Items.Add(btnTool); return btnTool; } //Get ButtonTool properties private string getSendername(object sender) { string result = "unknown"; if (sender is ButtonTool) { ButtonTool btool = sender as ButtonTool; result = "ButtonTool" + ":" + btool.Caption + " location:" + btool.Location.ToString(); result += "\nIsActine=" + btool.IsActive.ToString() + ",IsOnQat=" + btool.IsOnQat.ToString(); result += "\nHaImage=" + btool.HasImage.ToString() + ",IsQatCommonTool=" + btool.IsQatCommonTool.ToString(); result += "\nSizingMode=" + btool.SizingMode.ToString() + ",KeyTip=" + btool.KeyTip; result += "\nHasCaption=" + btool.HasCaption.ToString() + ",Id=" + btool.Id; result += "\nLargeImage=" + btool.LargeImage.ToString(); result += "\nSmallImage=" + btool.SmallImage.ToString(); } return result; } //Get Image Source private BitmapImage getImageSource(string uriString) { BitmapImage bmpImage = new BitmapImage(); bmpImage.BeginInit(); bmpImage.UriSource = new Uri(uriString, UriKind.RelativeOrAbsolute); bmpImage.EndInit(); return bmpImage; } //Add ButtonTool to RIbbonGroup private ButtonTool addButtonToolToRibbonGroup(RibbonGroup igRibbongroup, string caption, string tagString, string imageUriString) { ButtonTool btnTool = getButtonTool(caption, tagString, imageUriString); igRibbongroup.Items.Add(btnTool); return btnTool; } //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