-
-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathTableView.Properties.cs
More file actions
1139 lines (985 loc) · 44.1 KB
/
TableView.Properties.cs
File metadata and controls
1139 lines (985 loc) · 44.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Media;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using WinUI.TableView.Helpers;
namespace WinUI.TableView;
/// <summary>
/// Partial class for TableView that contains dependency properties and related methods.
/// </summary>
public partial class TableView
{
/// <summary>
/// Identifies the ItemsSource dependency property.
/// </summary>
public static readonly new DependencyProperty ItemsSourceProperty = DependencyProperty.Register(nameof(ItemsSource), typeof(object), typeof(TableView), new PropertyMetadata(null, OnItemsSourceChanged));
/// <summary>
/// Identifies the SelectionMode dependency property.
/// </summary>
public static readonly new DependencyProperty SelectionModeProperty = DependencyProperty.Register(nameof(SelectionMode), typeof(ListViewSelectionMode), typeof(TableView), new PropertyMetadata(ListViewSelectionMode.Extended, OnSelectionModeChanged));
/// <summary>
/// Identifies the HeaderRowHeight dependency property.
/// </summary>
public static readonly DependencyProperty HeaderRowHeightProperty = DependencyProperty.Register(nameof(HeaderRowHeight), typeof(double), typeof(TableView), new PropertyMetadata(double.NaN));
/// <summary>
/// Identifies the HeaderRowMaxHeight dependency property.
/// </summary>
public static readonly DependencyProperty HeaderRowMaxHeightProperty = DependencyProperty.Register(nameof(HeaderRowMaxHeight), typeof(double), typeof(TableView), new PropertyMetadata(double.PositiveInfinity));
/// <summary>
/// Identifies the HeaderRowMinHeight dependency property.
/// </summary>
public static readonly DependencyProperty HeaderRowMinHeightProperty = DependencyProperty.Register(nameof(HeaderRowMinHeight), typeof(double), typeof(TableView), new PropertyMetadata(32d));
/// <summary>
/// Identifies the RowHeight dependency property.
/// </summary>
public static readonly DependencyProperty RowHeightProperty = DependencyProperty.Register(nameof(RowHeight), typeof(double), typeof(TableView), new PropertyMetadata(double.NaN));
/// <summary>
/// Identifies the RowMaxHeight dependency property.
/// </summary>
public static readonly DependencyProperty RowMaxHeightProperty = DependencyProperty.Register(nameof(RowMaxHeight), typeof(double), typeof(TableView), new PropertyMetadata(double.PositiveInfinity));
/// <summary>
/// Identifies the RowMinHeight dependency property.
/// </summary>
public static readonly DependencyProperty RowMinHeightProperty = DependencyProperty.Register(nameof(RowMinHeight), typeof(double), typeof(TableView), new PropertyMetadata(40d));
/// <summary>
/// Identifies the ShowExportOptions dependency property.
/// </summary>
public static readonly DependencyProperty ShowExportOptionsProperty = DependencyProperty.Register(nameof(ShowExportOptions), typeof(bool), typeof(TableView), new PropertyMetadata(false));
/// <summary>
/// Identifies the AutoGenerateColumns dependency property.
/// </summary>
public static readonly DependencyProperty AutoGenerateColumnsProperty = DependencyProperty.Register(nameof(AutoGenerateColumns), typeof(bool), typeof(TableView), new PropertyMetadata(true, OnAutoGenerateColumnsChanged));
/// <summary>
/// Identifies the IsReadOnly dependency property.
/// </summary>
public static readonly DependencyProperty IsReadOnlyProperty = DependencyProperty.Register(nameof(IsReadOnly), typeof(bool), typeof(TableView), new PropertyMetadata(false, OnIsReadOnlyChanged));
/// <summary>
/// Identifies the CornerButtonMode dependency property.
/// </summary>
public static readonly DependencyProperty CornerButtonModeProperty = DependencyProperty.Register(nameof(CornerButtonMode), typeof(TableViewCornerButtonMode), typeof(TableView), new PropertyMetadata(TableViewCornerButtonMode.Options, OnCornerButtonModeChanged));
/// <summary>
/// Identifies the CanResizeColumns dependency property.
/// </summary>
public static readonly DependencyProperty CanResizeColumnsProperty = DependencyProperty.Register(nameof(CanResizeColumns), typeof(bool), typeof(TableView), new PropertyMetadata(true));
/// <summary>
/// Identifies the CanSortColumns dependency property.
/// </summary>
public static readonly DependencyProperty CanSortColumnsProperty = DependencyProperty.Register(nameof(CanSortColumns), typeof(bool), typeof(TableView), new PropertyMetadata(true));
/// <summary>
/// Identifies the CanFilterColumns dependency property.
/// </summary>
public static readonly DependencyProperty CanFilterColumnsProperty = DependencyProperty.Register(nameof(CanFilterColumns), typeof(bool), typeof(TableView), new PropertyMetadata(true, OnCanFilterColumnsChanged));
/// <summary>
/// Identifies the MinColumnWidth dependency property.
/// </summary>
public static readonly DependencyProperty MinColumnWidthProperty = DependencyProperty.Register(nameof(MinColumnWidth), typeof(double), typeof(TableView), new PropertyMetadata(50d, OnMinColumnWidthChanged));
/// <summary>
/// Identifies the MaxColumnWidth dependency property.
/// </summary>
public static readonly DependencyProperty MaxColumnWidthProperty = DependencyProperty.Register(nameof(MaxColumnWidth), typeof(double), typeof(TableView), new PropertyMetadata(double.PositiveInfinity, OnMaxColumnWidthChanged));
/// <summary>
/// Identifies the SelectionUnit dependency property.
/// </summary>
public static readonly DependencyProperty SelectionUnitProperty = DependencyProperty.Register(nameof(SelectionUnit), typeof(TableViewSelectionUnit), typeof(TableView), new PropertyMetadata(TableViewSelectionUnit.CellOrRow, OnSelectionUnitChanged));
/// <summary>
/// Identifies the HeaderGridLinesVisibility dependency property.
/// </summary>
public static readonly DependencyProperty HeaderGridLinesVisibilityProperty = DependencyProperty.Register(nameof(HeaderGridLinesVisibility), typeof(TableViewGridLinesVisibility), typeof(TableView), new PropertyMetadata(TableViewGridLinesVisibility.All, OnGridLinesPropertyChanged));
/// <summary>
/// Identifies the GridLinesVisibility dependency property.
/// </summary>
public static readonly DependencyProperty GridLinesVisibilityProperty = DependencyProperty.Register(nameof(GridLinesVisibility), typeof(TableViewGridLinesVisibility), typeof(TableView), new PropertyMetadata(TableViewGridLinesVisibility.All, OnGridLinesPropertyChanged));
/// <summary>
/// Identifies the HorizontalGridLinesStrokeThickness dependency property.
/// </summary>
public static readonly DependencyProperty HorizontalGridLinesStrokeThicknessProperty = DependencyProperty.Register(nameof(HorizontalGridLinesStrokeThickness), typeof(double), typeof(TableView), new PropertyMetadata(1d, OnGridLinesPropertyChanged));
/// <summary>
/// Identifies the VerticalGridLinesStrokeThickness dependency property.
/// </summary>
public static readonly DependencyProperty VerticalGridLinesStrokeThicknessProperty = DependencyProperty.Register(nameof(VerticalGridLinesStrokeThickness), typeof(double), typeof(TableView), new PropertyMetadata(1d, OnGridLinesPropertyChanged));
/// <summary>
/// Identifies the HorizontalGridLinesStroke dependency property.
/// </summary>
public static readonly DependencyProperty HorizontalGridLinesStrokeProperty = DependencyProperty.Register(nameof(HorizontalGridLinesStroke), typeof(Brush), typeof(TableView), new PropertyMetadata(default, OnGridLinesPropertyChanged));
/// <summary>
/// Identifies the VerticalGridLinesStroke dependency property.
/// </summary>
public static readonly DependencyProperty VerticalGridLinesStrokeProperty = DependencyProperty.Register(nameof(VerticalGridLinesStroke), typeof(Brush), typeof(TableView), new PropertyMetadata(default, OnGridLinesPropertyChanged));
/// <summary>
/// Identifies the AlternateRowForeground dependency property.
/// </summary>
public static readonly DependencyProperty AlternateRowForegroundProperty = DependencyProperty.Register(nameof(AlternateRowForeground), typeof(Brush), typeof(TableView), new PropertyMetadata(null, OnAlternateRowColorChanged));
/// <summary>
/// Identifies the AlternateRowBackground dependency property.
/// </summary>
public static readonly DependencyProperty AlternateRowBackgroundProperty = DependencyProperty.Register(nameof(AlternateRowBackground), typeof(Brush), typeof(TableView), new PropertyMetadata(null, OnAlternateRowColorChanged));
/// <summary>
/// Identifies the RowContextFlyout dependency property.
/// </summary>
public static readonly DependencyProperty RowContextFlyoutProperty = DependencyProperty.Register(nameof(RowContextFlyout), typeof(FlyoutBase), typeof(TableView), new PropertyMetadata(null));
/// <summary>
/// Identifies the CellContextFlyout dependency property.
/// </summary>
public static readonly DependencyProperty CellContextFlyoutProperty = DependencyProperty.Register(nameof(CellContextFlyout), typeof(FlyoutBase), typeof(TableView), new PropertyMetadata(null));
/// <summary>
/// Identifies the ColumnHeaderStyle dependency property.
/// </summary>
public static readonly DependencyProperty ColumnHeaderStyleProperty = DependencyProperty.Register(nameof(ColumnHeaderStyle), typeof(Style), typeof(TableView), new PropertyMetadata(null, OnColumnHeaderStyleChanged));
/// <summary>
/// Identifies the CellStyle dependency property.
/// </summary>
public static readonly DependencyProperty CellStyleProperty = DependencyProperty.Register(nameof(CellStyle), typeof(Style), typeof(TableView), new PropertyMetadata(null, OnCellStyleChanged));
/// <summary>
/// Identifies the CurrentCellSlot dependency property.
/// </summary>
public static readonly DependencyProperty CurrentCellSlotProperty = DependencyProperty.Register(nameof(CurrentCellSlot), typeof(TableViewCellSlot?), typeof(TableView), new PropertyMetadata(default, OnCurrentCellSlotChanged));
/// <summary>
/// Identifies the UseRightClickForColumnFilter dependency property.
/// </summary>
public static readonly DependencyProperty UseRightClickForColumnFilterProperty = DependencyProperty.Register(nameof(UseRightClickForColumnFilter), typeof(bool), typeof(TableView), new PropertyMetadata(false));
/// <summary>
/// Identifies the VerticalOffset dependency property.
/// </summary>
public static readonly DependencyProperty VerticalOffsetProperty = DependencyProperty.Register(nameof(VerticalOffset), typeof(double), typeof(TableView), new PropertyMetadata(0d));
/// <summary>
/// Identifies the HorizontalOffset dependency property.
/// </summary>
public static readonly DependencyProperty HorizontalOffsetProperty = DependencyProperty.Register(nameof(HorizontalOffset), typeof(double), typeof(TableView), new PropertyMetadata(0.0, OnHorizontalOffsetChanged));
/// <summary>
/// Identifies the RowHeaderActualWidth dependency property.
/// </summary>
public static readonly DependencyProperty RowHeaderActualWidthProperty = DependencyProperty.Register(nameof(RowHeaderActualWidth), typeof(double), typeof(TableView), new PropertyMetadata(0d, OnRowHeaderWidthChanged));
/// <summary>
/// Identifies the RowHeaderWidth dependency property.
/// </summary>
public static readonly DependencyProperty RowHeaderWidthProperty = DependencyProperty.Register(nameof(RowHeaderWidth), typeof(double), typeof(TableView), new PropertyMetadata(double.NaN, OnRowHeaderWidthChanged));
/// <summary>
/// Identifies the RowHeaderMinWidth dependency property.
/// </summary>
public static readonly DependencyProperty RowHeaderMinWidthProperty = DependencyProperty.Register(nameof(RowHeaderMinWidth), typeof(double), typeof(TableView), new PropertyMetadata(16d, OnRowHeaderWidthChanged));
/// <summary>
/// Identifies the RowHeaderMaxWidth dependency property.
/// </summary>
public static readonly DependencyProperty RowHeaderMaxWidthProperty = DependencyProperty.Register(nameof(RowHeaderMaxWidth), typeof(double), typeof(TableView), new PropertyMetadata(double.PositiveInfinity, OnRowHeaderWidthChanged));
/// <summary>
/// Identifies the HeadersVisibility dependency property.
/// </summary>
public static readonly DependencyProperty HeadersVisibilityProperty = DependencyProperty.Register(nameof(HeadersVisibility), typeof(TableViewHeadersVisibility), typeof(TableView), new PropertyMetadata(TableViewHeadersVisibility.All, OnRowHeadersVisibilityChanged));
/// <summary>
/// Identifies the RowHeaderContent dependency property.
/// </summary>
public static readonly DependencyProperty RowHeaderTemplateProperty = DependencyProperty.Register(nameof(RowHeaderTemplate), typeof(DataTemplate), typeof(TableView), new PropertyMetadata(null, OnRowHeaderTemplateChanged));
/// <summary>
/// Identifies the RowHeaderTemplateSelector dependency property.
/// </summary>
public static readonly DependencyProperty RowHeaderTemplateSelectorProperty = DependencyProperty.Register(nameof(RowHeaderTemplateSelector), typeof(DataTemplateSelector), typeof(TableView), new PropertyMetadata(null, OnRowHeaderTemplateChanged));
/// <summary>
/// Identifies the ColumnAutoWidthMode dependency property.
/// </summary>
public static readonly DependencyProperty ColumnAutoWidthModeProperty = DependencyProperty.Register(nameof(ColumnAutoWidthMode), typeof(ColumnAutoWidthMode), typeof(TableView), new PropertyMetadata(ColumnAutoWidthMode.Both));
/// <summary>
/// Identifies the FrozenColumnCount dependency property.
/// </summary>
public static readonly DependencyProperty FrozenColumnCountProperty = DependencyProperty.Register(nameof(FrozenColumnCount), typeof(int), typeof(TableView), new PropertyMetadata(0, OnFrozenColumnCountChanged));
/// <summary>
/// Identifies the RowDetailsVisibilityMode dependency property.
/// </summary>
public static readonly DependencyProperty RowDetailsVisibilityModeProperty = DependencyProperty.Register(nameof(RowDetailsVisibilityMode), typeof(TableViewRowDetailsVisibilityMode), typeof(TableView), new PropertyMetadata(TableViewRowDetailsVisibilityMode.VisibleWhenExpanded, OnRowDetailsVisibilityModeChanged));
/// <summary>
/// Identifies the RowDetailsTemplate dependency property.
/// </summary>
public static readonly DependencyProperty RowDetailsTemplateProperty = DependencyProperty.Register(nameof(RowDetailsTemplate), typeof(DataTemplate), typeof(TableView), new PropertyMetadata(null, OnRowDetailsTemplateChanged));
/// <summary>
/// Identifies the RowDetailsTemplateSelector dependency property.
/// </summary>
public static readonly DependencyProperty RowDetailsTemplateSelectorProperty = DependencyProperty.Register(nameof(RowDetailsTemplateSelector), typeof(DataTemplateSelector), typeof(TableView), new PropertyMetadata(null, OnRowDetailsTemplateChanged));
/// <summary>
/// Identifies the AreRowDetailsFrozen dependency property.
/// </summary>
public static readonly DependencyProperty AreRowDetailsFrozenProperty = DependencyProperty.Register(nameof(AreRowDetailsFrozen), typeof(bool), typeof(TableView), new PropertyMetadata(false, OnAreRowDetailsFrozen));
/// <summary>
/// Identifies the CellsVerticalOffset dependency property.
/// </summary>
public static readonly DependencyProperty CellsHorizontalOffsetProperty = DependencyProperty.Register(nameof(CellsHorizontalOffset), typeof(double), typeof(TableView), new PropertyMetadata(16d));
/// <summary>
/// Identifies the CanReorderColumns dependency property.
/// </summary>
public static readonly DependencyProperty CanReorderColumnsProperty = DependencyProperty.Register(nameof(CanReorderColumns), typeof(bool), typeof(TableView), new PropertyMetadata(true));
/// <summary>
/// Identifies the <see cref="ConditionalCellStyles"/> dependency property.
/// </summary>
public static readonly DependencyProperty ConditionalCellStylesProperty = DependencyProperty.Register(nameof(ConditionalCellStyles), typeof(IList<TableViewConditionalCellStyle>), typeof(TableView), new PropertyMetadata(default));
/// <summary>
/// Identifies the <see cref="ShowFilterItemsCount"/> dependency property.
/// </summary>
public static readonly DependencyProperty ShowFilterItemsCountProperty = DependencyProperty.Register(nameof(ShowFilterItemsCount), typeof(bool), typeof(TableView), new PropertyMetadata(false));
/// <summary>
/// Gets or sets a value indicating whether opening the column filter over header right-click is enabled.
/// </summary>
public bool UseRightClickForColumnFilter
{
get => (bool)GetValue(UseRightClickForColumnFilterProperty);
set => SetValue(UseRightClickForColumnFilterProperty, value);
}
/// <summary>
/// Gets the collection view associated with the TableView.
/// </summary>
public ICollectionView CollectionView => _collectionView;
/// <summary>
/// Gets the collection of sort descriptions applied to the items.
/// </summary>
public IList<SortDescription> SortDescriptions => _collectionView.SortDescriptions;
/// <summary>
/// Gets the collection of filter descriptions applied to the items.
/// </summary>
public IList<FilterDescription> FilterDescriptions => _collectionView.FilterDescriptions;
/// <summary>
/// Gets or sets a value indicating whether live shaping is enabled.
/// </summary>
public bool AllowLiveShaping
{
get => _collectionView.AllowLiveShaping;
set => _collectionView.AllowLiveShaping = value;
}
/// <summary>
/// Gets or sets the last selection unit used.
/// </summary>
internal TableViewSelectionUnit LastSelectionUnit { get; set; }
/// <summary>
/// Gets or sets the current cell slot associated with the table view.
/// </summary>
public TableViewCellSlot? CurrentCellSlot
{
get => (TableViewCellSlot?)GetValue(CurrentCellSlotProperty);
set => SetValue(CurrentCellSlotProperty, value);
}
/// <summary>
/// Gets or sets the collection of conditional cell styles.
/// </summary>
public IList<TableViewConditionalCellStyle> ConditionalCellStyles
{
get => (IList<TableViewConditionalCellStyle>)GetValue(ConditionalCellStylesProperty);
set => SetValue(ConditionalCellStylesProperty, value);
}
/// <summary>
/// Gets or sets a value that indicates whether the TableView displays items count next to each filter item in filter flyout.
/// </summary>
public bool ShowFilterItemsCount
{
get => (bool)GetValue(ShowFilterItemsCountProperty);
set => SetValue(ShowFilterItemsCountProperty, value);
}
/// <summary>
/// Gets or sets the selection start cell slot.
/// </summary>
internal TableViewCellSlot? SelectionStartCellSlot { get; set; }
/// <summary>
/// Gets or sets the selection start row index.
/// </summary>
internal int? SelectionStartRowIndex { get; set; }
/// <summary>
/// Gets or sets the current row index.
/// </summary>
internal int? CurrentRowIndex { get; set; }
/// <summary>
/// Gets or sets the selected cells.
/// </summary>
internal HashSet<TableViewCellSlot> SelectedCells { get; set; } = [];
/// <summary>
/// Gets the selected cell ranges.
/// </summary>
internal HashSet<HashSet<TableViewCellSlot>> SelectedCellRanges { get; } = [];
/// <summary>
/// Gets or sets a value indicating whether the TableView is in editing mode.
/// </summary>
internal bool IsEditing { get; private set; }
/// <summary>
/// Gets the visibility states of details pane for each item.
/// </summary>
internal ConditionalWeakTable<object, TValue<bool>> DetailsPaneStates { get; } = [];
/// <summary>
/// Gets or sets the filter handler for the TableView.
/// </summary>
public IColumnFilterHandler FilterHandler { get; set; }
/// <summary>
/// Gets a value indicating whether the TableView items are filtered.
/// </summary>
public bool IsFiltered => FilterDescriptions.Count > 0 || Columns.Any(x => x.IsFiltered) is true;
/// <summary>
/// Gets a value indicating whether the TableView items are sorted.
/// </summary>
public bool IsSorted => SortDescriptions.Count > 0 || Columns.Any(x => x.SortDirection is not null) is true;
/// <summary>
/// Gets the collection of columns in the TableView.
/// </summary>
public ITableViewColumnsCollection Columns { get; }
/// <summary>
/// Gets or sets the height of the header row.
/// </summary>
public double HeaderRowHeight
{
get => (double)GetValue(HeaderRowHeightProperty);
set => SetValue(HeaderRowHeightProperty, value);
}
/// <summary>
/// Gets or sets the max height of the header row.
/// </summary>
public double HeaderRowMaxHeight
{
get => (double)GetValue(HeaderRowMaxHeightProperty);
set => SetValue(HeaderRowMaxHeightProperty, value);
}
/// <summary>
/// Gets or sets the min height of the header row.
/// </summary>
public double HeaderRowMinHeight
{
get => (double)GetValue(HeaderRowMinHeightProperty);
set => SetValue(HeaderRowMinHeightProperty, value);
}
/// <summary>
/// Gets or sets the height of the rows.
/// </summary>
public double RowHeight
{
get => (double)GetValue(RowHeightProperty);
set => SetValue(RowHeightProperty, value);
}
/// <summary>
/// Gets or sets the maximum height of the rows.
/// </summary>
public double RowMaxHeight
{
get => (double)GetValue(RowMaxHeightProperty);
set => SetValue(RowMaxHeightProperty, value);
}
/// <summary>
/// Gets or sets the minimum height of the rows.
/// </summary>
public double RowMinHeight
{
get => (double)GetValue(RowMinHeightProperty);
set => SetValue(RowMinHeightProperty, value);
}
/// <summary>
/// Gets or sets an object source used to generate the content of the TableView.
/// </summary>
public new object? ItemsSource
{
get => GetValue(ItemsSourceProperty);
set => SetValue(ItemsSourceProperty, value);
}
/// <summary>
/// Gets or sets the selection mode for the TableView.
/// </summary>
public new ListViewSelectionMode SelectionMode
{
get => (ListViewSelectionMode)GetValue(SelectionModeProperty);
set => SetValue(SelectionModeProperty, value);
}
/// <summary>
/// Gets or sets a value indicating whether to show export options.
/// </summary>
public bool ShowExportOptions
{
get => (bool)GetValue(ShowExportOptionsProperty);
set => SetValue(ShowExportOptionsProperty, value);
}
/// <summary>
/// Gets or sets a value indicating whether to auto-generate columns.
/// </summary>
public bool AutoGenerateColumns
{
get => (bool)GetValue(AutoGenerateColumnsProperty);
set => SetValue(AutoGenerateColumnsProperty, value);
}
/// <summary>
/// Gets or sets a value indicating whether the TableView is read-only. This will override what is set on individual column.
/// </summary>
public bool IsReadOnly
{
get => (bool)GetValue(IsReadOnlyProperty);
set => SetValue(IsReadOnlyProperty, value);
}
/// <summary>
/// Gets or sets the mode of the corner button.
/// </summary>
public TableViewCornerButtonMode CornerButtonMode
{
get => (TableViewCornerButtonMode)GetValue(CornerButtonModeProperty);
set => SetValue(CornerButtonModeProperty, value);
}
/// <summary>
/// Gets or sets a value indicating whether columns can be resized. This will override what is set on individual column.
/// </summary>
public bool CanResizeColumns
{
get => (bool)GetValue(CanResizeColumnsProperty);
set => SetValue(CanResizeColumnsProperty, value);
}
/// <summary>
/// Gets or sets a value indicating whether columns can be sorted. This will overridden by individual column.
/// </summary>
public bool CanSortColumns
{
get => (bool)GetValue(CanSortColumnsProperty);
set => SetValue(CanSortColumnsProperty, value);
}
/// <summary>
/// Gets or sets a value indicating whether columns can be filtered. This will overridden by the individual column.
/// </summary>
public bool CanFilterColumns
{
get => (bool)GetValue(CanFilterColumnsProperty);
set => SetValue(CanFilterColumnsProperty, value);
}
/// <summary>
/// Gets or sets the minimum width of columns. This can be overridden by the individual column.
/// </summary>
public double MinColumnWidth
{
get => (double)GetValue(MinColumnWidthProperty);
set => SetValue(MinColumnWidthProperty, value);
}
/// <summary>
/// Gets or sets the maximum width of columns. This can be override by setting MaxWidth on individual column.
/// </summary>
public double MaxColumnWidth
{
get => (double)GetValue(MaxColumnWidthProperty);
set => SetValue(MaxColumnWidthProperty, value);
}
/// <summary>
/// Gets or sets the selection unit for the TableView.
/// </summary>
public TableViewSelectionUnit SelectionUnit
{
get => (TableViewSelectionUnit)GetValue(SelectionUnitProperty);
set => SetValue(SelectionUnitProperty, value);
}
/// <summary>
/// Gets or sets the visibility of grid lines in the header row.
/// </summary>
public TableViewGridLinesVisibility HeaderGridLinesVisibility
{
get => (TableViewGridLinesVisibility)GetValue(HeaderGridLinesVisibilityProperty);
set => SetValue(HeaderGridLinesVisibilityProperty, value);
}
/// <summary>
/// Gets or sets the visibility of grid lines in the body rows.
/// </summary>
public TableViewGridLinesVisibility GridLinesVisibility
{
get => (TableViewGridLinesVisibility)GetValue(GridLinesVisibilityProperty);
set => SetValue(GridLinesVisibilityProperty, value);
}
/// <summary>
/// Gets or sets the thickness of vertical grid lines.
/// </summary>
public double VerticalGridLinesStrokeThickness
{
get => (double)GetValue(VerticalGridLinesStrokeThicknessProperty);
set => SetValue(VerticalGridLinesStrokeThicknessProperty, value);
}
/// <summary>
/// Gets or sets the thickness of horizontal grid lines.
/// </summary>
public double HorizontalGridLinesStrokeThickness
{
get => (double)GetValue(HorizontalGridLinesStrokeThicknessProperty);
set => SetValue(HorizontalGridLinesStrokeThicknessProperty, value);
}
/// <summary>
/// Gets or sets the brush used to draw vertical grid lines.
/// </summary>
public Brush VerticalGridLinesStroke
{
get => (Brush)GetValue(VerticalGridLinesStrokeProperty);
set => SetValue(VerticalGridLinesStrokeProperty, value);
}
/// <summary>
/// Gets or sets the brush used to draw horizontal grid lines.
/// </summary>
public Brush HorizontalGridLinesStroke
{
get => (Brush)GetValue(HorizontalGridLinesStrokeProperty);
set => SetValue(HorizontalGridLinesStrokeProperty, value);
}
/// <summary>
/// Gets or sets the background brush for alternate rows.
/// </summary>
public Brush AlternateRowBackground
{
get => (Brush)GetValue(AlternateRowBackgroundProperty);
set => SetValue(AlternateRowBackgroundProperty, value);
}
/// <summary>
/// Gets or sets the foreground brush for alternate rows.
/// </summary>
public Brush AlternateRowForeground
{
get => (Brush)GetValue(AlternateRowForegroundProperty);
set => SetValue(AlternateRowForegroundProperty, value);
}
/// <summary>
/// Gets or sets the context flyout for rows.
/// </summary>
public FlyoutBase? RowContextFlyout
{
get => (FlyoutBase?)GetValue(RowContextFlyoutProperty);
set => SetValue(RowContextFlyoutProperty, value);
}
/// <summary>
/// Gets or sets the context flyout for cells.
/// </summary>
public FlyoutBase? CellContextFlyout
{
get => (FlyoutBase?)GetValue(CellContextFlyoutProperty);
set => SetValue(CellContextFlyoutProperty, value);
}
/// <summary>
/// Gets or sets the style applied to all column headers.
/// </summary>
public Style ColumnHeaderStyle
{
get => (Style)GetValue(ColumnHeaderStyleProperty);
set => SetValue(ColumnHeaderStyleProperty, value);
}
/// <summary>
/// Gets or sets the style applied to all cells.
/// </summary>
public Style CellStyle
{
get => (Style)GetValue(CellStyleProperty);
set => SetValue(CellStyleProperty, value);
}
/// <summary>
/// Gets the vertical offset for the TableView.
/// </summary>
public double VerticalOffset => (double)GetValue(VerticalOffsetProperty);
/// <summary>
/// Gets the horizontal offset for the TableView.
/// </summary>
public double HorizontalOffset => (double)GetValue(HorizontalOffsetProperty);
/// <summary>
/// Gets the actual width of the row header.
/// </summary>
public double RowHeaderActualWidth => (double)GetValue(RowHeaderActualWidthProperty);
/// <summary>
/// Gets or sets the width of the row header.
/// </summary>
public double RowHeaderWidth
{
get => (double)GetValue(RowHeaderWidthProperty);
set => SetValue(RowHeaderWidthProperty, value);
}
/// <summary>
/// Gets or sets the minimum width of the row header.
/// </summary>
public double RowHeaderMinWidth
{
get => (double)GetValue(RowHeaderMinWidthProperty);
set => SetValue(RowHeaderMinWidthProperty, value);
}
/// <summary>
/// Gets or sets the maximum width of the row header.
/// </summary>
public double RowHeaderMaxWidth
{
get => (double)GetValue(RowHeaderMaxWidthProperty);
set => SetValue(RowHeaderMaxWidthProperty, value);
}
/// <summary>
/// Gets or sets the visibility of the row and column headers.
/// </summary>
public TableViewHeadersVisibility HeadersVisibility
{
get => (TableViewHeadersVisibility)GetValue(HeadersVisibilityProperty);
set => SetValue(HeadersVisibilityProperty, value);
}
/// <summary>
/// Gets or sets the data template for the row header.
/// </summary>
public DataTemplate? RowHeaderTemplate
{
get => (DataTemplate?)GetValue(RowHeaderTemplateProperty);
set => SetValue(RowHeaderTemplateProperty, value);
}
/// <summary>
/// Gets or sets the data template selector for the row header.
/// </summary>
public DataTemplateSelector RowHeaderTemplateSelector
{
get => (DataTemplateSelector)GetValue(RowHeaderTemplateSelectorProperty);
set => SetValue(RowHeaderTemplateSelectorProperty, value);
}
/// <summary>
/// Gets or sets the ColumnAutoWidthMode for all columns.
/// </summary>
public ColumnAutoWidthMode ColumnAutoWidthMode
{
get => (ColumnAutoWidthMode)GetValue(ColumnAutoWidthModeProperty);
set => SetValue(ColumnAutoWidthModeProperty, value);
}
/// <summary>
/// Gets or sets the number of columns that stays in view on horizontal scroll.
/// </summary>
public int FrozenColumnCount
{
get => (int)GetValue(FrozenColumnCountProperty);
set => SetValue(FrozenColumnCountProperty, value);
}
/// <summary>
/// Gets or sets the visibility mode of the row details.
/// </summary>
public TableViewRowDetailsVisibilityMode RowDetailsVisibilityMode
{
get => (TableViewRowDetailsVisibilityMode)GetValue(RowDetailsVisibilityModeProperty);
set => SetValue(RowDetailsVisibilityModeProperty, value);
}
/// <summary>
/// Gets or sets the data template for the row details.
/// </summary>
public DataTemplate? RowDetailsTemplate
{
get => (DataTemplate?)GetValue(RowDetailsTemplateProperty);
set => SetValue(RowDetailsTemplateProperty, value);
}
/// <summary>
/// Gets or sets the data template selector for the row details.
/// </summary>
public DataTemplateSelector RowDetailsTemplateSelector
{
get => (DataTemplateSelector)GetValue(RowDetailsTemplateSelectorProperty);
set => SetValue(RowDetailsTemplateSelectorProperty, value);
}
/// <summary>
/// Gets or sets a value indicating whether the row details are frozen during horizontal scrolling.
/// </summary>
public bool AreRowDetailsFrozen
{
get => (bool)GetValue(AreRowDetailsFrozenProperty);
set => SetValue(AreRowDetailsFrozenProperty, value);
}
/// <summary>
/// Gets or sets the horizontal offset for the cells.
/// </summary>
public double CellsHorizontalOffset
{
get => (double)GetValue(CellsHorizontalOffsetProperty);
internal set => SetValue(CellsHorizontalOffsetProperty, value);
}
/// <summary>
/// Gets or sets a value indicating whether columns can be reordered by dragging headers.
/// </summary>
public bool CanReorderColumns
{
get => (bool)GetValue(CanReorderColumnsProperty);
set => SetValue(CanReorderColumnsProperty, value);
}
/// <summary>
/// Handles changes to the ItemsSource property.
/// </summary>
private static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TableView tableView)
{
tableView.ItemsSourceChanged(e);
tableView.SelectedCellRanges.Clear();
tableView.OnCellSelectionChanged();
}
}
/// <summary>
/// Handles changes to the SelectionMode property.
/// </summary>
private static void OnSelectionModeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TableView tableView)
{
if (tableView.SelectionMode is ListViewSelectionMode.Single or ListViewSelectionMode.None)
{
var currentCell = tableView.CurrentCellSlot.HasValue ? tableView.GetCellFromSlot(tableView.CurrentCellSlot.Value) : default;
currentCell?.ApplyCurrentCellState();
tableView.SelectedCellRanges.Clear();
if (tableView.SelectionMode is ListViewSelectionMode.Single && tableView.CurrentCellSlot.HasValue)
{
tableView.SelectedCellRanges.Add([tableView.CurrentCellSlot.Value]);
}
tableView.OnCellSelectionChanged();
}
tableView.UpdateBaseSelectionMode();
tableView.UpdateCornerButtonState();
}
}
/// <summary>
/// Handles changes to the AutoGenerateColumns property.
/// </summary>
private static void OnAutoGenerateColumnsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TableView tableView)
{
if (tableView.AutoGenerateColumns)
{
tableView.EnsureAutoColumns(true);
}
else
{
tableView.RemoveAutoGeneratedColumns();
}
}
}
/// <summary>
/// Handles changes to the CornerButtonMode property.
/// </summary>
private static void OnCornerButtonModeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TableView tableView)
{
tableView.UpdateCornerButtonState();
}
}
/// <summary>
/// Handles changes to the IsReadOnly property.
/// </summary>
private static void OnIsReadOnlyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TableView tableView)
{
tableView.OnIsReadOnlyChanged(e);
if ((tableView.SelectionMode is ListViewSelectionMode.None
|| tableView.SelectionUnit is TableViewSelectionUnit.Row)
&& tableView.IsReadOnly)
{
tableView.CurrentCellSlot = null;
}
}
}
/// <summary>
/// Handles changes to the CanFilterColumns property.
/// </summary>
private static void OnCanFilterColumnsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TableView tableView && tableView._headerRow is not null)
{
foreach (var header in tableView._headerRow.Headers)
{
header.SetFilterButtonVisibility();
}
}
}
/// <summary>
/// Handles changes to the MinColumnWidth property.
/// </summary>
private static void OnMinColumnWidthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TableView table && table._headerRow is not null)
{
table._headerRow.CalculateHeaderWidths();
}
}
/// <summary>
/// Handles changes to the MaxColumnWidth property.
/// </summary>
private static void OnMaxColumnWidthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TableView table && table._headerRow is not null)
{
table._headerRow.CalculateHeaderWidths();
}
}
/// <summary>
/// Handles changes to the SelectionUnit property.
/// </summary>
private static void OnSelectionUnitChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TableView tableView)
{
if (tableView.SelectionUnit is TableViewSelectionUnit.Row)
{
tableView.SelectedCellRanges.Clear();
tableView.OnCellSelectionChanged();
}
tableView.UpdateBaseSelectionMode();
tableView.UpdateCornerButtonState();
}
}
/// <summary>
/// Handles changes to the grid lines properties.
/// </summary>
private static void OnGridLinesPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TableView tableView)
{
tableView.EnsureGridLines();
}
}
/// <summary>
/// Handles changes to the alternate row color properties.
/// </summary>
private static void OnAlternateRowColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TableView tableView)
{
tableView.EnsureAlternateRowColors();
}
}
/// <summary>
/// Handles changes to the ColumnHeaderStyle property.
/// </summary>
private static void OnColumnHeaderStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TableView tableView)
{
tableView.EnsureColumnHeadersStyle();
}
}
/// <summary>
/// Handles changes to the CellStyle property.
/// </summary>
private static void OnCellStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TableView tableView)
{
tableView.EnsureCellsStyle();
}
}
private static async void OnCurrentCellSlotChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is not TableView tableView) return;
tableView.OnCurrentCellChanged(e);
var oldSlot = e.OldValue as TableViewCellSlot?;
var newSlot = e.NewValue as TableViewCellSlot?;
await tableView.OnCurrentCellChanged(oldSlot, newSlot);
}