@@ -26,6 +26,7 @@ namespace MahApps.Metro.Controls
2626 [ TemplatePart ( Name = PART_DownButton , Type = typeof ( Button ) ) ]
2727 [ TemplatePart ( Name = PART_BannerGrid , Type = typeof ( Grid ) ) ]
2828 [ TemplatePart ( Name = PART_BannerLabel , Type = typeof ( Label ) ) ]
29+ [ TemplatePart ( Name = PART_Index , Type = typeof ( ListBox ) ) ]
2930 [ StyleTypedProperty ( Property = nameof ( NavigationButtonStyle ) , StyleTargetType = typeof ( Button ) ) ]
3031 [ StyleTypedProperty ( Property = nameof ( IndexItemContainerStyle ) , StyleTargetType = typeof ( ListBoxItem ) ) ]
3132 public class FlipView : Selector
@@ -696,13 +697,15 @@ public string ButtonDownContentStringFormat
696697 private const string PART_ForwardButton = "PART_ForwardButton" ;
697698 private const string PART_Presenter = "PART_Presenter" ;
698699 private const string PART_UpButton = "PART_UpButton" ;
700+ private const string PART_Index = "PART_Index" ;
699701 /// <summary>
700702 /// To counteract the double Loaded event issue.
701703 /// </summary>
702704 private bool loaded ;
703705 private bool allowSelectedIndexChangedCallback = true ;
704706 private Grid bannerGrid ;
705707 private Label bannerLabel ;
708+ private ListBox indexListBox ;
706709 private Button backButton ;
707710 private Button forwardButton ;
708711 private Button downButton ;
@@ -859,6 +862,11 @@ public override void OnApplyTemplate()
859862
860863 this . presenter = this . GetTemplateChild ( PART_Presenter ) as TransitioningContentControl ;
861864
865+ if ( this . indexListBox != null )
866+ {
867+ this . indexListBox . SelectionChanged -= OnIndexListBoxSelectionChanged ;
868+ }
869+
862870 if ( this . forwardButton != null )
863871 {
864872 this . forwardButton . Click -= this . NextButtonClick ;
@@ -879,6 +887,8 @@ public override void OnApplyTemplate()
879887 this . downButton . Click -= this . NextButtonClick ;
880888 }
881889
890+ this . indexListBox = this . GetTemplateChild ( PART_Index ) as ListBox ;
891+
882892 this . forwardButton = this . GetTemplateChild ( PART_ForwardButton ) as Button ;
883893 this . backButton = this . GetTemplateChild ( PART_BackButton ) as Button ;
884894 this . upButton = this . GetTemplateChild ( PART_UpButton ) as Button ;
@@ -911,6 +921,22 @@ public override void OnApplyTemplate()
911921 {
912922 this . bannerLabel . Opacity = this . IsBannerEnabled ? 1d : 0d ;
913923 }
924+
925+ this . ExecuteWhenLoaded ( ( ) =>
926+ {
927+ if ( this . indexListBox != null )
928+ {
929+ this . indexListBox . SelectionChanged += OnIndexListBoxSelectionChanged ;
930+ }
931+ } ) ;
932+ }
933+
934+ private void OnIndexListBoxSelectionChanged ( object sender , SelectionChangedEventArgs e )
935+ {
936+ if ( ReferenceEquals ( e . OriginalSource , this . indexListBox ) )
937+ {
938+ e . Handled = true ;
939+ }
914940 }
915941
916942 protected override DependencyObject GetContainerForItemOverride ( )
0 commit comments