Skip to content

Instantly share code, notes, and snippets.

View rdelrosario's full-sized avatar

Rendy Del Rosario rdelrosario

View GitHub Profile
_sourceCache.Edit((update) =>
{
update.AddOrUpdate(new Restaurant(name, "Casual", "Fast Food", "US"));
});
using System;
using System.Collections.ObjectModel;
using System.Reactive.Linq;
using DynamicData;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace DynamicDataGroupingSample
{
public class MainViewModel : IDisposable
<ListView ItemsSource="{Binding Restaurants}">
<ListView.ItemTemplate>
<DataTemplate x:DataType="local:Restaurant">
<TextCell Text="{Binding Name}"
Detail="{Binding Type}"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
_cleanUp = _sourceCache.Connect()
.RefCount()
.Bind(out _restaurants)
.DisposeMany()
.Subscribe();
using System;
namespace DynamicDataGroupingSample
{
public class Restaurant
{
public Restaurant(string name, string category, string type, string country)
{
Id = Guid.NewGuid().ToString();
Name = name;
Category = category;
_sourceCache.AddOrUpdate(new List<Restaurant>()
{
new Restaurant("Yao","Casual","Asian Fusion","Dominican Republic"),
new Restaurant("Chef Pepper","Casual","International","Dominican Republic"),
new Restaurant("Bottega Fratelli","Formal","International","Dominican Republic"),
new Restaurant("McDonalds","Fast Food","Burgers","United States"),
new Restaurant("Burger King","Fast Food","Burgers","United States"),
new Restaurant("Sushi Nation","Casual","Sushi","Venezuela"),
new Restaurant("Pollo Victorina","Fast Food","Chicken","Dominican Republic"),
new Restaurant("Pollo Rey","Fast Food","Chicken","Dominican Republic"),
public ReadOnlyObservableCollection<Restaurant> Restaurants => _restaurants;
private readonly ReadOnlyObservableCollection<Restaurant> _restaurants;
private SourceCache<Restaurant, string> _sourceCache = new SourceCache<Restaurant, string>(x => x.Id);
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="LoginPage">
<StackLayout>
<Button TextColor="Red" x:Name="login" Text="Register" BackgroundColor="Beige" BorderColor="Pink" Command="{Binding LoginCommand}" />
<Button x:Name="registerBtn" TextColor="Firebrick" Text="Login" BackgroundColor="Firebrick" BorderColor="Green" Command="{Binding RegisterCommand}"/>
<Image Source="user" HorizontalOptions="End">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="UserTapped"/>
</Image.GestureRecognizers>
<Style x:Key="HeaderLabelStyle" TargetType="Label">
<Setter Property="FontAttributes" Value="Bold" />
<Setter Property="Padding" Value="10" />
<Setter Property="TextColor" Value="Gray" />
</Style>