summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1747.xaml.cs
blob: 4d6e56da011aea8779627c9b85f76cd5c8fd95e0 (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
61
62
63
64
65
66
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;

using Xamarin.Forms;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

namespace Xamarin.Forms.Controls
{

	public class ViewModel : INotifyPropertyChanged
	{
		bool _shouldBeToggled;
		public bool ShouldBeToggled {
			get { return _shouldBeToggled; }
			set 
			{
				_shouldBeToggled = value;
				OnPropertyChanged ();
			}
		}

		bool _shouldBeEnabled;
		public bool ShouldBeEnabled {
			get { return _shouldBeEnabled; }
			set 
			{
				_shouldBeEnabled = value;
				OnPropertyChanged ();
			}
		}

		public event PropertyChangedEventHandler PropertyChanged;

		protected virtual void OnPropertyChanged ([CallerMemberName] string propertyName = null)
		{
			PropertyChangedEventHandler handler = PropertyChanged;
			if (handler != null)
				handler (this, new PropertyChangedEventArgs (propertyName));
		}
	}
#if APP
	[Preserve (AllMembers=true)]
	[Issue (IssueTracker.Github, 1747, "Binding to Switch.IsEnabled has no effect", PlatformAffected.WinPhone)]
	public partial class Issue1747 : ContentPage
	{
		readonly ViewModel _vm;

		public Issue1747 ()
		{
			_vm = new ViewModel ();
			BindingContext = _vm;
			InitializeComponent ();
		}

		public void Button_OnClick (object sender, EventArgs args)
		{
			_vm.ShouldBeToggled = !_vm.ShouldBeToggled;
			_vm.ShouldBeEnabled = !_vm.ShouldBeEnabled;
		}
	}
#endif
}