From the course: Extending Xamarin with Behaviors, Commands, and Triggers
Unlock this course with a free trial
Join today to access over 22,400 courses taught by industry experts.
ListView data trigger - Xamarin Tutorial
From the course: Extending Xamarin with Behaviors, Commands, and Triggers
ListView data trigger
- [Instructor] Okay, now that we have everything prepared for our app, let's start by creating a trigger for our ListView. We want to make sure our ListView doesn't get shown when a to do list is empty. Let's go ahead and get started. I'm going to go to my ListView, and I'm going to add our ListView.Triggers field, and what we're going to be doing here is adding a DataTrigger that relates to the count of the to do list items in order for it to be shown as invisible. So in our new tag, going to go ahead and add a DataTrigger, and I'm going to a TargetType as the ListView. DataTriggers use the binding parameter to check whether or not a data binding element has a certain value. We're going to be using our to do list in our binding context. So I'm going add binding, I'm going to select my source, and I'm going to reference the TodoListPage, and I'm going set the path to BindingContext, which is our view model, and let's put that capital O to a lowercase O. BindingContext.TodoList, and we…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.