7

I have a simple question. I have two datatemplates defined on my Xamarin Forms page. I want to swap one in for the other when a button is pressed. I know with a ListView I can use the ItemTemplate and bind to my DataTemplateSelector to change views for the items in the list.

But I just want to swap something like a View/StackLayout/Frame by running the DataTemplateSelector on a button click or similar. But I can't find any controls that offer an ItemTemplate list ListView.

Is there a control that can accomplish this?

Jonesopolis
  • 25,034
  • 12
  • 68
  • 112

1 Answers1

0

Creating a custom control that would switch between 2 different views should not be that hard. You can expose a bindable property as a trigger for switching between views and handle the "switch" logic in the custom control it self.

I didn't try myself but it should be possible to work with DataTemplateSelectors in custom controls as well. More information can be found here and here.

EvZ
  • 11,889
  • 4
  • 38
  • 76