This repository was archived by the owner on Apr 29, 2024. It is now read-only.
File tree 2 files changed +62
-18
lines changed
UserInterface/ListView/SwitchEntryTwoBinding/twoWayBinding/twoWayBinding
2 files changed +62
-18
lines changed Original file line number Diff line number Diff line change 1
- using System ;
2
- using System . ComponentModel ;
3
- using Xamarin . Forms ;
1
+ using System . ComponentModel ;
4
2
using System . Runtime . CompilerServices ;
3
+ using Xamarin . Forms ;
5
4
6
5
namespace twoWayBinding
7
6
{
8
- public class light : INotifyPropertyChanged
7
+ public class light : INotifyPropertyChanged
9
8
{
10
9
public event PropertyChangedEventHandler PropertyChanged ;
11
10
12
11
private string _name ;
13
12
private string _comment ;
14
13
private Color _color ;
15
14
private bool _isOn ;
16
- public string name { get { return _name ; } set { OnPropertyChanged ( ) ; _name = value ; } }
17
- public string comment { get { return _comment ; } set { OnPropertyChanged ( ) ; _comment = value ; } }
18
- public Color color { get { return _color ; } set { OnPropertyChanged ( ) ; _color = value ; } }
19
- public bool isOn { get { return _isOn ; } set { OnPropertyChanged ( ) ; OnPropertyChanged ( "isNotOn" ) ; _isOn = value ; } }
15
+
16
+ public string name
17
+ {
18
+ get { return _name ; }
19
+ set
20
+ {
21
+ _name = value ;
22
+ OnPropertyChanged ( ) ;
23
+ }
24
+ }
25
+
26
+ public string comment
27
+ {
28
+ get { return _comment ; }
29
+ set
30
+ {
31
+ _comment = value ;
32
+ OnPropertyChanged ( ) ;
33
+ }
34
+ }
35
+
36
+ public Color color
37
+ {
38
+ get { return _color ; }
39
+ set
40
+ {
41
+ _color = value ;
42
+ OnPropertyChanged ( ) ;
43
+ }
44
+ }
45
+
46
+ public bool isOn
47
+ {
48
+ get { return _isOn ; }
49
+ set
50
+ {
51
+ _isOn = value ;
52
+ OnPropertyChanged ( ) ;
53
+ OnPropertyChanged ( "isNotOn" ) ;
54
+ }
55
+ }
56
+
20
57
public bool isNotOn { get { return ! _isOn ; } }
21
58
22
59
public light ( )
@@ -26,13 +63,15 @@ public light ()
26
63
this . color = Color . Blue ;
27
64
this . comment = "Bedroom" ;
28
65
}
66
+
29
67
public light ( bool isOn , string name , Color color , string comment )
30
68
{
31
69
this . isOn = isOn ;
32
70
this . name = name ;
33
71
this . color = color ;
34
72
this . comment = comment ;
35
73
}
74
+
36
75
void OnPropertyChanged ( [ CallerMemberName ] string propertyName = null )
37
76
{
38
77
var handler = PropertyChanged ;
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" UTF-8" ?>
2
- <ContentPage xmlns =" http://xamarin.com/schemas/2014/forms" xmlns : x =" http://schemas.microsoft.com/winfx/2009/xaml" x : Class =" twoWayBinding.EntryPage" Title =" Naming Panel" xmlns : local =" clr-namespace:twoWayBinding;assembly=twoWayBinding" >
3
- <ContentPage .Content>
4
- <ListView x : Name =" listView" SeparatorVisibility =" None" ItemsSource =" {x:Static local:HomeViewModel.lights}" >
5
- <ListView .ItemTemplate>
6
- <DataTemplate >
7
- <EntryCell Label =" {Binding comment}" Text =" {Binding name}" />
8
- </DataTemplate >
9
- </ListView .ItemTemplate>
10
- </ListView >
11
- </ContentPage .Content>
2
+ <ContentPage xmlns =" http://xamarin.com/schemas/2014/forms"
3
+ xmlns : x =" http://schemas.microsoft.com/winfx/2009/xaml"
4
+ xmlns : local =" clr-namespace:twoWayBinding;assembly=twoWayBinding"
5
+ x : Class =" twoWayBinding.EntryPage"
6
+ Title =" Naming Panel" >
7
+ <ListView x : Name =" listView"
8
+ SeparatorVisibility =" None"
9
+ ItemsSource =" {x:Static local:HomeViewModel.lights}" >
10
+ <ListView .ItemTemplate>
11
+ <DataTemplate >
12
+ <EntryCell Label =" {Binding comment}"
13
+ Text =" {Binding name}" />
14
+ </DataTemplate >
15
+ </ListView .ItemTemplate>
16
+ </ListView >
12
17
</ContentPage >
You can’t perform that action at this time.
0 commit comments