This file contains hidden or 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
<ContentPage.ToolbarItems> | |
<ToolbarItem Text="Sort" Command="{Binding SortCommand,Mode=OneTime}"/> | |
</ContentPage.ToolbarItems> | |
... | |
This file contains hidden or 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
namespace DynamicDataGroupingSample | |
{ | |
public class MainViewModel : ReactiveObject, IDisposable | |
{ | |
public MainViewModel() | |
{ | |
... | |
//Filter logic | |
Func<Restaurant, bool> countryFilter(string country) => restaurant => | |
{ |
This file contains hidden or 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
<Picker Title="Choose Country | |
SelectedItem="{Binding SelectedCountryFilter}"> | |
<Picker.Items> | |
<x:String>All</x:String> | |
<x:String>United States</x:String> | |
<x:String>Venezuela</x:String> | |
<x:String>Dominican Republic</x:String> | |
<x:String>Colombia</x:String> | |
</Picker.Items> | |
</Picker> |
This file contains hidden or 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
namespace DynamicDataGroupingSample | |
{ | |
public class MainViewModel : ReactiveObject, IDisposable | |
{ | |
public MainViewModel() | |
{ | |
// Initial data | |
_sourceCache.AddOrUpdate(new List<Restaurant>() | |
{ | |
new Restaurant("Yao","Casual","Asian Fusion","Dominican Republic"), |
This file contains hidden or 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
<SearchBar Text="{Binding SearchText}" /> | |
<ListView ItemsSource="{Binding Restaurants}"> | |
<ListView.ItemTemplate> | |
<DataTemplate x:DataType="local:Restaurant"> | |
<TextCell Text="{Binding Name}" | |
Detail="{Binding Type}"/> | |
</DataTemplate> | |
</ListView.ItemTemplate> | |
</ListView> |
This file contains hidden or 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
_cleanUp = _sourceCache.Connect() | |
.RefCount() | |
.Filter(filterPredicate) | |
.Bind(out _restaurants) | |
.DisposeMany() | |
.Subscribe(); |
This file contains hidden or 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
var filterPredicate = this.WhenAnyValue(x => x.SearchText) | |
.Throttle(TimeSpan.FromMilliseconds(250), RxApp.TaskpoolScheduler) | |
.DistinctUntilChanged() | |
.Select(restaurantFilter); |
This file contains hidden or 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
Func<Restaurant, bool> restaurantFilter(string text) => restaurant => | |
{ | |
return string.IsNullOrEmpty(text) || restaurant.Name.ToLower().Contains(text.ToLower()) || restaurant.Type.ToLower().Contains(text.ToLower()); | |
}; |
This file contains hidden or 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
namespace DynamicDataGroupingSample | |
{ | |
public class MainViewModel : ReactiveObject | |
{ | |
public MainViewModel() { ... } | |
public string SearchText | |
{ | |
get => _searchText; | |
set => this.RaiseAndSetIfChanged(ref _searchText, value); |
This file contains hidden or 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
_sourceCache.Edit((update) => | |
{ | |
update.Remove(restaurant); | |
}); |