'宣言 Public ReadOnly Property SelectedItem As UltraExplorerBarItem
public UltraExplorerBarItem SelectedItem {get;}
Imports Infragistics.Win Imports Infragistics.Win.UltraWinExplorerBar ' Handles the Form's 'Load' event Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' Hook the NavigationPaneCollapsed event AddHandler Me.ultraExplorerBar1.NavigationPaneFlyoutDisplayed, AddressOf Me.ultraExplorerBar1_NavigationPaneFlyoutDisplayed End Sub ' Handles the ExplorerBar's 'NavigationPaneFlyoutDisplayed' event Private Sub ultraExplorerBar1_NavigationPaneFlyoutDisplayed(ByVal sender As Object, ByVal e As EventArgs) Dim explorerBar As UltraExplorerBar = sender ' Deregister from the notification list since we won't need this ' until after the NavigationPaneFlyoutClosed event is fired RemoveHandler explorerBar.NavigationPaneFlyoutDisplayed, AddressOf Me.ultraExplorerBar1_NavigationPaneFlyoutDisplayed ' Register as a listener for the NavigationPaneFlyoutClosed event AddHandler explorerBar.NavigationPaneFlyoutClosed, AddressOf Me.ultraExplorerBar1_NavigationPaneFlyoutClosed End Sub ' Handles the ExplorerBar's 'NavigationPaneFlyoutDisplayed' event Private Sub ultraExplorerBar1_NavigationPaneFlyoutClosed(ByVal sender As Object, ByVal e As NavigationPaneFlyoutClosedEventArgs) Dim explorerBar As UltraExplorerBar = sender ' Deregister from the notification list since we won't need this ' until after the NavigationPaneFlyoutDisplayed event is fired RemoveHandler explorerBar.NavigationPaneFlyoutClosed, AddressOf Me.ultraExplorerBar1_NavigationPaneFlyoutClosed ' Register as a listener for the NavigationPaneFlyoutDisplayed event AddHandler explorerBar.NavigationPaneFlyoutDisplayed, AddressOf Me.ultraExplorerBar1_NavigationPaneFlyoutDisplayed If (e.Canceled = False AndAlso Not e.SelectedItem Is Nothing) Then Debug.WriteLine(String.Format("Item '{0}' selected.", e.SelectedItem.Text)) End If End Sub
using Infragistics.Win; using Infragistics.Win.UltraWinExplorerBar; using System.Diagnostics; // Handles the Form's 'Load' event. private void Form1_Load(object sender, System.EventArgs e) { // Hook the NavigationPaneFlyoutDisplayed event this.ultraExplorerBar1.NavigationPaneFlyoutDisplayed += new EventHandler( this.ultraExplorerBar1_NavigationPaneFlyoutDisplayed ); } // Handles the ExplorerBar's 'NavigationPaneExpanded' event. private void ultraExplorerBar1_NavigationPaneFlyoutDisplayed( object sender, EventArgs e ) { UltraExplorerBar explorerBar = sender as UltraExplorerBar; // Deregister from the notification list since we won't need this // until after the NavigationPaneFlyoutClosed event is fired explorerBar.NavigationPaneFlyoutDisplayed -= new EventHandler( this.ultraExplorerBar1_NavigationPaneFlyoutDisplayed ); // Register as a listener for the NavigationPaneFlyoutClosed event explorerBar.NavigationPaneFlyoutClosed += new NavigationPaneFlyoutClosedEventHandler( this.ultraExplorerBar1_NavigationPaneFlyoutClosed ); } // Handles the ExplorerBar's 'NavigationPaneFlyoutClosed' event. private void ultraExplorerBar1_NavigationPaneFlyoutClosed( object sender, NavigationPaneFlyoutClosedEventArgs e ) { UltraExplorerBar explorerBar = sender as UltraExplorerBar; // Deregister from the notification list since we won't need this // until after the NavigationPaneFlyoutDisplayed event is fired explorerBar.NavigationPaneFlyoutClosed -= new NavigationPaneFlyoutClosedEventHandler( this.ultraExplorerBar1_NavigationPaneFlyoutClosed ); // Register as a listener for the NavigationPaneFlyoutDisplayed event explorerBar.NavigationPaneFlyoutDisplayed += new EventHandler( this.ultraExplorerBar1_NavigationPaneFlyoutDisplayed ); if ( e.Canceled == false && e.SelectedItem != null ) { Debug.WriteLine( string.Format( "Item '{0}' selected.", e.SelectedItem.Text ) ); } }