@@ -113,6 +113,15 @@ public event EventHandler<RoutedEventArgs> SelectionChanged
113113 remove { RemoveHandler ( SelectionChangedEvent , value ) ; }
114114 }
115115
116+ public static readonly RoutedEvent < RoutedEventArgs > RowsChangedEvent =
117+ RoutedEvent . Register < BranchTree , RoutedEventArgs > ( nameof ( RowsChanged ) , RoutingStrategies . Tunnel | RoutingStrategies . Bubble ) ;
118+
119+ public event EventHandler < RoutedEventArgs > RowsChanged
120+ {
121+ add { AddHandler ( RowsChangedEvent , value ) ; }
122+ remove { RemoveHandler ( RowsChangedEvent , value ) ; }
123+ }
124+
116125 public BranchTree ( )
117126 {
118127 InitializeComponent ( ) ;
@@ -123,6 +132,14 @@ public void UnselectAll()
123132 BranchesPresenter . SelectedItem = null ;
124133 }
125134
135+ protected override void OnSizeChanged ( SizeChangedEventArgs e )
136+ {
137+ base . OnSizeChanged ( e ) ;
138+
139+ if ( Bounds . Height >= 23.0 )
140+ BranchesPresenter . Height = Bounds . Height ;
141+ }
142+
126143 protected override void OnPropertyChanged ( AvaloniaPropertyChangedEventArgs change )
127144 {
128145 base . OnPropertyChanged ( change ) ;
@@ -138,18 +155,20 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
138155 Rows . AddRange ( rows ) ;
139156 }
140157
141- var repo = this . FindAncestorOfType < Repository > ( ) ;
142- repo ? . UpdateLeftSidebarLayout ( ) ;
158+ RaiseEvent ( new RoutedEventArgs ( RowsChangedEvent ) ) ;
143159 }
144160 else if ( change . Property == IsVisibleProperty )
145161 {
146- var repo = this . FindAncestorOfType < Repository > ( ) ;
147- repo ? . UpdateLeftSidebarLayout ( ) ;
162+ RaiseEvent ( new RoutedEventArgs ( RowsChangedEvent ) ) ;
148163 }
149164 }
150165
151166 private void OnNodesSelectionChanged ( object _ , SelectionChangedEventArgs e )
152167 {
168+ var repo = DataContext as ViewModels . Repository ;
169+ if ( repo ? . Settings == null )
170+ return ;
171+
153172 foreach ( var item in e . AddedItems )
154173 {
155174 if ( item is ViewModels . BranchTreeNode node )
@@ -167,10 +186,7 @@ private void OnNodesSelectionChanged(object _, SelectionChangedEventArgs e)
167186 return ;
168187
169188 if ( selected . Count == 1 && selected [ 0 ] is ViewModels . BranchTreeNode { Backend : Models . Branch branch } )
170- {
171- var repo = DataContext as ViewModels . Repository ;
172- repo ? . NavigateToCommit ( branch . Head ) ;
173- }
189+ repo . NavigateToCommit ( branch . Head ) ;
174190
175191 var prev = null as ViewModels . BranchTreeNode ;
176192 foreach ( var row in Rows )
@@ -285,8 +301,7 @@ private void OnDoubleTappedBranchNode(object sender, TappedEventArgs _)
285301 rows . RemoveRange ( idx + 1 , removeCount ) ;
286302 }
287303
288- var repo = this . FindAncestorOfType < Repository > ( ) ;
289- repo ? . UpdateLeftSidebarLayout ( ) ;
304+ RaiseEvent ( new RoutedEventArgs ( RowsChangedEvent ) ) ;
290305 }
291306 }
292307 }
0 commit comments