Skip to content

Instantly share code, notes, and snippets.

@rmarinho
Created May 11, 2016 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmarinho/ed8105c53d13770005529ceb6bc9f820 to your computer and use it in GitHub Desktop.
Save rmarinho/ed8105c53d13770005529ceb6bc9f820 to your computer and use it in GitHub Desktop.
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