Last active
December 12, 2017 21:13
-
-
Save aybarsyalcin/9a8b74c801a600671cc2e4cd17d9f697 to your computer and use it in GitHub Desktop.
Listview with SwitchCell & Itemsource of Listview is set to "ItemsSource="{x:Static local:HomeViewModel.lights}"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.ComponentModel; | |
using System.Collections.ObjectModel; | |
namespace twoWayBinding | |
{ | |
public static class HomeViewModel | |
{ | |
public static ObservableCollection<light> lights { get; set; } | |
static HomeViewModel () | |
{ | |
HomeViewModel.lights = DataSource.getLights (); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
?xml version="1.0" encoding="UTF-8"?> | |
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" | |
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | |
x:Class="twoWayBinding.SwitchPage" | |
Title="Switch Panel" | |
xmlns:local="clr-namespace:twoWayBinding;assembly=twoWayBinding"> | |
<ContentPage.Content> | |
<ListView x:Name="listView" SeparatorVisibility="None" ItemsSource="{x:Static local:HomeViewModel.lights}"> | |
<ListView.ItemTemplate> | |
<DataTemplate> | |
<SwitchCell Text="{Binding name}" On="{Binding isOn}" /> | |
</DataTemplate> | |
</ListView.ItemTemplate> | |
</ListView> | |
</ContentPage.Content> | |
</ContentPage> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment