-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathTableViewBoundColumn.cs
More file actions
104 lines (91 loc) · 3.6 KB
/
Copy pathTableViewBoundColumn.cs
File metadata and controls
104 lines (91 loc) · 3.6 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
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;
namespace WinUI.TableView;
/// <summary>
/// Represents a column in a TableView that is bound to a data source.
/// </summary>
public abstract class TableViewBoundColumn : TableViewColumn
{
private Binding _binding = new();
/// <summary>
/// Gets the property path for the binding.
/// </summary>
internal string? PropertyPath => Binding?.Path?.Path;
/// <summary>
/// Gets or sets the binding for the column.
/// </summary>
public virtual Binding Binding
{
get => _binding;
set
{
if (_binding != value)
{
if (value is not null)
{
value.Mode = BindingMode.TwoWay;
if (value.UpdateSourceTrigger == UpdateSourceTrigger.Default)
{
value.UpdateSourceTrigger = UpdateSourceTrigger.Explicit;
}
}
_binding = value!;
}
}
}
/// <summary>
/// Gets or sets the optional data binding used to perform operations on cell content, for example sorting, filtering and exporting.
/// If no explicit operation binding is set, the column's <see cref="Binding"/> is returned as a fallback.
/// </summary>
public override Binding? OperationContentBinding
{
get => base.OperationContentBinding ?? Binding;
set => base.OperationContentBinding = value;
}
/// <summary>
/// Handles changes to the ElementStyle property.
/// </summary>
private static void OnElementStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TableViewColumn column && column.OwningCollection is { })
{
column.OwningCollection.HandleColumnPropertyChanged(column, nameof(ElementStyle));
}
}
/// <summary>
/// Handles changes to the EditingElementStyle property.
/// </summary>
private static void OnEditingElementStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TableViewColumn column && column.OwningCollection is { })
{
column.OwningCollection.HandleColumnPropertyChanged(column, nameof(EditingElementStyle));
}
}
/// <summary>
/// Gets or sets the style that is used when rendering the element that the column
/// displays for a cell that is not in editing mode.
/// </summary>
public Style ElementStyle
{
get => (Style)GetValue(ElementStyleProperty);
set => SetValue(ElementStyleProperty, value);
}
/// <summary>
/// Gets or sets the style that is used when rendering the element that the column
/// displays for a cell in editing mode.
/// </summary>
public Style EditingElementStyle
{
get => (Style)GetValue(EditingElementStyleProperty);
set => SetValue(EditingElementStyleProperty, value);
}
/// <summary>
/// Identifies the <see cref="ElementStyle"/> dependency property.
/// </summary>
public static readonly DependencyProperty ElementStyleProperty = DependencyProperty.Register(nameof(ElementStyle), typeof(Style), typeof(TableViewBoundColumn), new PropertyMetadata(null, OnElementStyleChanged));
/// <summary>
/// Identifies the <see cref="EditingElementStyle"/> dependency property.
/// </summary>
public static readonly DependencyProperty EditingElementStyleProperty = DependencyProperty.Register(nameof(EditingElementStyle), typeof(Style), typeof(TableViewBoundColumn), new PropertyMetadata(null, OnEditingElementStyleChanged));
}