This repository was archived by the owner on Apr 29, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +62
-18
lines changed
UserInterface/ListView/SwitchEntryTwoBinding/twoWayBinding/twoWayBinding Expand file tree Collapse file tree 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 ;
42using System . Runtime . CompilerServices ;
3+ using Xamarin . Forms ;
54
65namespace twoWayBinding
76{
8- public class light : INotifyPropertyChanged
7+ public class light : INotifyPropertyChanged
98 {
109 public event PropertyChangedEventHandler PropertyChanged ;
1110
1211 private string _name ;
1312 private string _comment ;
1413 private Color _color ;
1514 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+
2057 public bool isNotOn { get { return ! _isOn ; } }
2158
2259 public light ( )
@@ -26,13 +63,15 @@ public light ()
2663 this . color = Color . Blue ;
2764 this . comment = "Bedroom" ;
2865 }
66+
2967 public light ( bool isOn , string name , Color color , string comment )
3068 {
3169 this . isOn = isOn ;
3270 this . name = name ;
3371 this . color = color ;
3472 this . comment = comment ;
3573 }
74+
3675 void OnPropertyChanged ( [ CallerMemberName ] string propertyName = null )
3776 {
3877 var handler = PropertyChanged ;
Original file line number Diff line number Diff line change 11<?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 >
1217</ContentPage >
You can’t perform that action at this time.
0 commit comments