'宣言 Public Property SelectedItem As GalleryItem
public GalleryItem SelectedItem {get; set;}
この読み取り/書き込みプロパティをコードまたは XAML に直接設定できるので、ItemBehavior プロパティが 'StateButton' に設定され、ユーザーが GalleryItem をクリックすると、自動的に設定されます。
注: SelectionDisplayMode プロパティは、GalleryItem のどの部分(存在する場合)が選択時に視覚的に強調表示されるかを決定します。
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); } } } }