Press "Enter" to skip to content

Multi-Selection per row with Dynamic Data in Xamarin Forms (Part 4)

In the third part of the series about Dynamic Data, we covered how to group items. In this part, we will explora how to do multi-selection per row, reusing the concepts of grouping that we learned in the previous article.

Multi-Selection per row

As an example, we are going to create the following notifications settings page:

It has two groups Development and Administration. Inside each group, we will have these channels: Sms, Email, Push, Phone.

Let’s start!

1.Create your Model

Make sure to implement PropertyChanged in the selectable properties: SmsChannel, PhoneChannel, EmailChannel and PushNotificationChannel. Since we want to detect when the checkbox has changed its state in any of them.

Note: Copy the ReactiveObjExt class here.

2.Create the Grouping List

In the ViewModel, let’s create a SourceCache and add a few items.

Note: Copy here ObservableGroupedCollection class, here.

3.Observe channel state changes

To observe when a channel has changed its state, we are going to create a reactive pipeline for each channel using WhenPropertyChanged, also using Throttle we will limit notifications emissions when selecting. Finally, will use InvokeCommand to subscribe and invoke a command when the state changes.

4.Create the UI

If you haven’t fallen in love with Dynamic Data yet, stay tuned for the next part of this series with some more Dynamic Data magic tricks.

Check the full source code here.

Happy Dynamic Data!

One Comment

Comments are closed.