@@ -17,15 +17,6 @@ namespace SourceGit.Views
1717{
1818 public class BranchTreeNodeIcon : UserControl
1919 {
20- public static readonly StyledProperty < ViewModels . BranchTreeNode > NodeProperty =
21- AvaloniaProperty . Register < BranchTreeNodeIcon , ViewModels . BranchTreeNode > ( nameof ( Node ) ) ;
22-
23- public ViewModels . BranchTreeNode Node
24- {
25- get => GetValue ( NodeProperty ) ;
26- set => SetValue ( NodeProperty , value ) ;
27- }
28-
2920 public static readonly StyledProperty < bool > IsExpandedProperty =
3021 AvaloniaProperty . Register < BranchTreeNodeIcon , bool > ( nameof ( IsExpanded ) ) ;
3122
@@ -35,16 +26,23 @@ public bool IsExpanded
3526 set => SetValue ( IsExpandedProperty , value ) ;
3627 }
3728
38- static BranchTreeNodeIcon ( )
29+ protected override void OnDataContextChanged ( EventArgs e )
30+ {
31+ base . OnDataContextChanged ( e ) ;
32+ UpdateContent ( ) ;
33+ }
34+
35+ protected override void OnPropertyChanged ( AvaloniaPropertyChangedEventArgs change )
3936 {
40- NodeProperty . Changed . AddClassHandler < BranchTreeNodeIcon > ( ( icon , _ ) => icon . UpdateContent ( ) ) ;
41- IsExpandedProperty . Changed . AddClassHandler < BranchTreeNodeIcon > ( ( icon , _ ) => icon . UpdateContent ( ) ) ;
37+ base . OnPropertyChanged ( change ) ;
38+
39+ if ( change . Property == IsExpandedProperty )
40+ UpdateContent ( ) ;
4241 }
4342
4443 private void UpdateContent ( )
4544 {
46- var node = Node ;
47- if ( node == null )
45+ if ( DataContext is not ViewModels . BranchTreeNode node )
4846 {
4947 Content = null ;
5048 return ;
0 commit comments