@@ -26,6 +26,7 @@ namespace MahApps.Metro.Controls
26
26
[ TemplatePart ( Name = PART_DownButton , Type = typeof ( Button ) ) ]
27
27
[ TemplatePart ( Name = PART_BannerGrid , Type = typeof ( Grid ) ) ]
28
28
[ TemplatePart ( Name = PART_BannerLabel , Type = typeof ( Label ) ) ]
29
+ [ TemplatePart ( Name = PART_Index , Type = typeof ( ListBox ) ) ]
29
30
[ StyleTypedProperty ( Property = nameof ( NavigationButtonStyle ) , StyleTargetType = typeof ( Button ) ) ]
30
31
[ StyleTypedProperty ( Property = nameof ( IndexItemContainerStyle ) , StyleTargetType = typeof ( ListBoxItem ) ) ]
31
32
public class FlipView : Selector
@@ -696,13 +697,15 @@ public string ButtonDownContentStringFormat
696
697
private const string PART_ForwardButton = "PART_ForwardButton" ;
697
698
private const string PART_Presenter = "PART_Presenter" ;
698
699
private const string PART_UpButton = "PART_UpButton" ;
700
+ private const string PART_Index = "PART_Index" ;
699
701
/// <summary>
700
702
/// To counteract the double Loaded event issue.
701
703
/// </summary>
702
704
private bool loaded ;
703
705
private bool allowSelectedIndexChangedCallback = true ;
704
706
private Grid bannerGrid ;
705
707
private Label bannerLabel ;
708
+ private ListBox indexListBox ;
706
709
private Button backButton ;
707
710
private Button forwardButton ;
708
711
private Button downButton ;
@@ -859,6 +862,11 @@ public override void OnApplyTemplate()
859
862
860
863
this . presenter = this . GetTemplateChild ( PART_Presenter ) as TransitioningContentControl ;
861
864
865
+ if ( this . indexListBox != null )
866
+ {
867
+ this . indexListBox . SelectionChanged -= OnIndexListBoxSelectionChanged ;
868
+ }
869
+
862
870
if ( this . forwardButton != null )
863
871
{
864
872
this . forwardButton . Click -= this . NextButtonClick ;
@@ -879,6 +887,8 @@ public override void OnApplyTemplate()
879
887
this . downButton . Click -= this . NextButtonClick ;
880
888
}
881
889
890
+ this . indexListBox = this . GetTemplateChild ( PART_Index ) as ListBox ;
891
+
882
892
this . forwardButton = this . GetTemplateChild ( PART_ForwardButton ) as Button ;
883
893
this . backButton = this . GetTemplateChild ( PART_BackButton ) as Button ;
884
894
this . upButton = this . GetTemplateChild ( PART_UpButton ) as Button ;
@@ -911,6 +921,22 @@ public override void OnApplyTemplate()
911
921
{
912
922
this . bannerLabel . Opacity = this . IsBannerEnabled ? 1d : 0d ;
913
923
}
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
+ }
914
940
}
915
941
916
942
protected override DependencyObject GetContainerForItemOverride ( )
0 commit comments