'Declaration Public Property SelectedItem As GalleryItem
public GalleryItem SelectedItem {get; set;}
While this read-write property can be set directly in code or XAML, it will be automatically set if the the ItemBehavior property is set to 'StateButton' and the user clicks on a GalleryItem.
Note: The SelectionDisplayMode property determines what part (if any) of the GalleryItem is visually highlighted when it is selected.
Imports System Imports System.Windows Imports Infragistics.Windows.Ribbon Namespace MyNamespace Public Partial Class MyWindow Inherits XamRibbonWindow Public Sub New() InitializeComponent() End Sub Private Sub SetupGalleryTool() AddHandler galleryTool.ItemSelected, AddressOf OnItemSelected End Sub Private Sub OnItemSelected(ByVal sender As Object, ByVal e As Infragistics.Windows.Ribbon.Events.GalleryItemEventArgs) Dim item As GalleryItem = Me.galleryTool.SelectedItem If item IsNot Nothing Then Console.WriteLine("The selected item text is: {0}", item.Text) End If End Sub End Class End Namespace
using System; using System.Windows; using Infragistics.Windows.Ribbon; namespace MyNamespace { public partial class MyWindow : XamRibbonWindow { public MyWindow() { InitializeComponent(); } private void SetupGalleryTool() { galleryTool.ItemSelected += new EventHandler<Infragistics.Windows.Ribbon.Events.GalleryItemEventArgs>(OnItemSelected); } private void OnItemSelected(object sender, Infragistics.Windows.Ribbon.Events.GalleryItemEventArgs e) { GalleryItem item = this.galleryTool.SelectedItem; if (item != null) { Console.WriteLine("The selected item text is: {0}", item.Text); } } } }
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