blob: 60ef6d956b35bc5365909f724ec8f3573e740d2a (
plain)
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
|
using System;
using System.Collections.Specialized;
using System.ComponentModel;
namespace Xamarin.Forms
{
public sealed class TableRoot : TableSectionBase<TableSection>
{
public TableRoot()
{
SetupEvents();
}
public TableRoot(string title) : base(title)
{
SetupEvents();
}
internal event EventHandler<ChildCollectionChangedEventArgs> SectionCollectionChanged;
void ChildCollectionChanged(object sender, NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs)
{
EventHandler<ChildCollectionChangedEventArgs> handler = SectionCollectionChanged;
if (handler != null)
handler(this, new ChildCollectionChangedEventArgs(notifyCollectionChangedEventArgs));
}
void ChildPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
{
if (propertyChangedEventArgs.PropertyName == TitleProperty.PropertyName)
{
OnPropertyChanged(TitleProperty.PropertyName);
}
}
void SetupEvents()
{
CollectionChanged += (sender, args) =>
{
if (args.NewItems != null)
{
foreach (TableSection section in args.NewItems)
{
section.CollectionChanged += ChildCollectionChanged;
section.PropertyChanged += ChildPropertyChanged;
}
}
if (args.OldItems != null)
{
foreach (TableSection section in args.OldItems)
{
section.CollectionChanged -= ChildCollectionChanged;
section.PropertyChanged -= ChildPropertyChanged;
}
}
};
}
}
}
|