-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathFlexDemoPageViewModel.cs
30 lines (26 loc) · 1.05 KB
/
FlexDemoPageViewModel.cs
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
using System.Windows.Input;
using Xamarin.Forms;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace Flex.Demo
{
public class FlexDemoPageViewModel : INotifyPropertyChanged
{
public bool IsButtonEnabled = true;
bool isToggled;
public bool IsToggled
{
get { return isToggled; }
set { isToggled = value; OnPropertyChanged(); }
}
// Just demonstrates the use of Commands
Command buttonClickedCommand;
public Command ButtonClickedCommand => buttonClickedCommand ?? (buttonClickedCommand = new Command(() =>
{
Application.Current.MainPage.DisplayAlert("Hello from the View Model", "The Flex Button rocks!", "Yeah");
}, () => IsButtonEnabled));
// Implementation of INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
void OnPropertyChanged([CallerMemberName] string name = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
}