0

I'm trying to create a custom cell renderer in Xamarin. To do so, I need to return a Windows.UI.Xaml.DataTemplate. When I search for how to create one in code, the only documentation I can find is here, but that doesn't create the DataTemplate in code, it creates some XML and then hands it off to the parser. How do I create a DataTemplate in C#?

Simon
  • 25,468
  • 44
  • 152
  • 266
  • What about this http://stackoverflow.com/a/5592399/734040 ? – Decade Moon Oct 03 '16 at 10:26
  • @DecadeMoon no joy, I'm afraid. When I tried the approach they describe, it didn't work because there's no `DataType` property on `Windows.UI.Xaml.DataTemplate`. – Simon Oct 03 '16 at 12:21
  • I also don't see any documentation on doing this via code. However, why do you need to code it in C#? DataTemplates are much easier to create via XAML. You can use a custom renderer with that, explained here: https://developer.xamarin.com/guides/xamarin-forms/custom-renderer/viewcell/#Creating_the_Custom_Renderer_on_Windows_Phone_and_UWP – therealjohn Oct 04 '16 at 13:02

0 Answers0