File tree 3 files changed +16
-3
lines changed
src/Avalonia.Controls.TreeDataGrid/Primitives
3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -250,7 +250,12 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
250
250
base . OnPropertyChanged ( change ) ;
251
251
}
252
252
253
- internal void UpdateRowIndex ( int index ) => RowIndex = index ;
253
+ internal void UpdateRowIndex ( int index )
254
+ {
255
+ if ( RowIndex == - 1 )
256
+ throw new InvalidOperationException ( "Cell is not realized." ) ;
257
+ RowIndex = index ;
258
+ }
254
259
255
260
internal void UpdateSelection ( ITreeDataGridSelectionInteraction ? selection )
256
261
{
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ public void Realize(int index)
35
35
{
36
36
if ( RowIndex != - 1 )
37
37
throw new InvalidOperationException ( "Row is already realized." ) ;
38
- UpdateRowIndex ( index ) ;
38
+ RowIndex = index ;
39
39
InvalidateMeasure ( ) ;
40
40
}
41
41
@@ -51,6 +51,9 @@ public void UpdateRowIndex(int index)
51
51
{
52
52
if ( index < 0 || Rows is null || index >= Rows . Count )
53
53
throw new ArgumentOutOfRangeException ( nameof ( index ) ) ;
54
+ if ( RowIndex == - 1 )
55
+ throw new InvalidOperationException ( "Row is not realized." ) ;
56
+
54
57
RowIndex = index ;
55
58
56
59
foreach ( var element in RealizedElements )
Original file line number Diff line number Diff line change @@ -83,8 +83,9 @@ public void Realize(
83
83
Rows = rows ;
84
84
DataContext = rows ? [ rowIndex ] . Model ;
85
85
IsSelected = selection ? . IsRowSelected ( rowIndex ) ?? false ;
86
- UpdateIndex ( rowIndex ) ;
86
+ RowIndex = rowIndex ;
87
87
UpdateSelection ( selection ) ;
88
+ CellsPresenter ? . Realize ( rowIndex ) ;
88
89
_treeDataGrid ? . RaiseRowPrepared ( this , RowIndex ) ;
89
90
}
90
91
@@ -95,6 +96,9 @@ public void Realize(
95
96
96
97
public void UpdateIndex ( int index )
97
98
{
99
+ if ( RowIndex == - 1 )
100
+ throw new InvalidOperationException ( "Row is not realized." ) ;
101
+
98
102
RowIndex = index ;
99
103
CellsPresenter ? . UpdateRowIndex ( index ) ;
100
104
}
@@ -107,6 +111,7 @@ public void Unrealize()
107
111
IsSelected = false ;
108
112
CellsPresenter ? . Unrealize ( ) ;
109
113
}
114
+
110
115
protected override void OnAttachedToLogicalTree ( LogicalTreeAttachmentEventArgs e )
111
116
{
112
117
_treeDataGrid = this . FindLogicalAncestorOfType < TreeDataGrid > ( ) ;
You can’t perform that action at this time.
0 commit comments