Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sample of ListView with GroupDisplayBinding
var lv = new ListView {BindingContext = fooViewModel, IsGroupingEnabled = true, GroupDisplayBinding = new Binding ("Name")};
public class FooViewModel
{
List<Group<string>> _things;
public List<Group<string>> Things {
get
{
return _things ?? (_things = new List<Group<string>> {
new Group<string>(new []{"A","B","C","D","E","F","G","H","I","J","K"}) {Name = "Letters", Key ="L"},
new Group<string>(new []{"1","2","3","4","5","6","7","8","9","10"}) {Name = "Numbers", Key ="N"}
});
}
}
bool _canExecute;
public bool CanExecute {
get
{
return _canExecute;
}
set {
_canExecute = value;
RefreshThingsCommand.ChangeCanExecute ();
}
}
Command _refreshThingsCommand;
public Command RefreshThingsCommand {
get {return _refreshThingsCommand ?? (_refreshThingsCommand = new Command (BeginRefreshThings, () => _canExecute ));}
}
protected void BeginRefreshThings()
{
}
}
public class Group<T> : ObservableCollection<T>
{
public Group (IEnumerable<T> seed) : base(seed){}
public string Name {
get;
set;
}
public string Key {
get;
set;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment