Skip to content

Instantly share code, notes, and snippets.

View rdelrosario's full-sized avatar

Rendy Del Rosario rdelrosario

View GitHub Profile
mBraintreeFragment = BraintreeFragment.NewInstance(CrossCurrentActivity.Current.Activity, clientToken);
PayPal.RequestOneTimePayment(mBraintreeFragment, new PayPalRequest($"{amount}"));
PayPal.AuthorizeAccount(mBraintreeFragment);
<ListView ItemsSource="{Binding RestaurantsGrouped}"
GroupDisplayBinding="{Binding Key}"
IsGroupingEnabled="True">
...
</ListView>
_sourceCache.Connect()
.Filter(countryPredicate)
.Group(x => x.Category)
.Transform(g => new ObservableGroupedCollection<string, Restaurant, string>(g, filterPredicate, sortPredicate))
.Sort(SortExpressionComparer<ObservableGroupedCollection<string, Restaurant, string>>.Ascending(a => a.Key))
.Bind(out _restaurants)
.DisposeMany()
.Subscribe();
public class ObservableGroupedCollection<TGroupKey, TObject, TKey> : ObservableCollectionExtended<TObject>, IDisposable
{
public TGroupKey Key { get; }
public ObservableGroupedCollection(IGroup<TObject, TKey, TGroupKey> group, IObservable<Func<TObject, bool>> filter, IObservable<IComparer<TObject>> comparer)
{
this.Key = group.Key;
//load and sort the grouped list
var dataLoader = group.Cache.Connect()
public ReadOnlyObservableCollection<ObservableGroupedCollection<string, Restaurant, string>> RestaurantsGrouped => _restaurants;
private readonly ReadOnlyObservableCollection<ObservableGroupedCollection<string, Restaurant, string>> _restaurants;
_sourceCache.Connect()
.RefCount()
.Filter(countryPredicate)
.Filter(filterPredicate)
.Sort(sortPredicate)
.Bind(out _restaurants)
.DisposeMany()
.Subscribe();
var sortPredicate = this.WhenAnyValue(x => x.SortBy)
.Select(x => x == "Type" ? SortExpressionComparer<Restaurant>.Ascending(a => a.Type) : SortExpressionComparer<Restaurant>.Ascending(a => a.Name));
namespace DynamicDataGroupingSample
{
public class MainViewModel : ReactiveObject, IDisposable
{
public MainViewModel()
{
SortCommand = ReactiveCommand.CreateFromTask(ExecuteSort);
}
private async Task ExecuteSort()
{