Created
May 11, 2016 15:58
-
-
Save rmarinho/ed8105c53d13770005529ceb6bc9f820 to your computer and use it in GitHub Desktop.
Sample of ListView with GroupDisplayBinding
This file contains 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 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