Bug 41710 - [UWP] Using DataTemplates in CustomRenderer throws Exception
Summary: [UWP] Using DataTemplates in CustomRenderer throws Exception
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-06-10 16:49 UTC by Anubhav Ranjan
Modified: 2017-01-09 23:31 UTC (History)
2 users (show)

Tags: ac
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Anubhav Ranjan 2016-06-10 16:49:00 UTC
I am running into an issue with a custom renderer and I am not sure where else to go – so I am sending a support request (I have received n response on line in any forum or medium)

I am trying to use the following line of code in a Windows UWP renderer

ItemTemplate = (WDataTemplate)WApp.Current.Resources["ItemTemplate"]

And I am getting a resource key note found exception and I just do not understand why

The renderer declaration looks like
public class HorizontalListViewRenderer : ViewRenderer<HorizontalListView, FrameworkElement>

and the XAML looks like this

<control:HorizontalListView ItemsSource="{Binding Items}">
<StackLayout Padding="15,0,15,0">
<Label Text="{Binding Title}" TextColor="#323232">
<OnPlatform x:TypeArguments="x:Double"
iOS="18" />
</ control:HorizontalListView.ItemTemplate>
</control:HorizontalListView >


#Version Info:
Microsoft Visual Studio Enterprise 2015
Version 14.0.25123.00 Update 2
Microsoft .NET Framework
Version 4.6.01038

Installed Version: Enterprise

Architecture and Modeling Tools   00322-80000-00000-AA004
Microsoft Architecture and Modeling Tools
UML® and Unified Modeling Language™ are trademarks or registered trademarks of the Object Management Group, Inc. in the United States and other countries.

Visual Basic 2015   00322-80000-00000-AA004
Microsoft Visual Basic 2015

Visual C# 2015   00322-80000-00000-AA004
Microsoft Visual C# 2015

Visual C++ 2015   00322-80000-00000-AA004
Microsoft Visual C++ 2015

Windows Phone SDK 8.0 - ENU   00322-80000-00000-AA004
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package   5.208.60602.2
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2015.1   14.1.20512.0
ASP.NET and Web Tools 2015.1

ASP.NET Web Frameworks and Tools 2012.2   4.1.41102.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.40314.0
For additional information, visit http://www.asp.net/

Azure App Service Tools v2.8.1   14.0.11123.0
Azure App Service Tools v2.8.1

Common Azure Tools   1.7
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

JetBrains ReSharper Ultimate 10.0.2   Build 104.0.20151218.120627
JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2016 JetBrains, Inc.

Microsoft .NET Core Tools (Preview 1)   14.1.20512.0
Microsoft .NET Core Tools (Preview 1)

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

NuGet Package Manager   3.4.4
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   14.0.60311.1
Microsoft SQL Server Data Tools

TypeScript tools for Visual Studio

Visual Studio Tools for Universal Windows Apps   14.0.25219.00
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

Xamarin (a532c82)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android (804c6cb)
Visual Studio extension to enable development for Xamarin.Android.

Xamarin.iOS (3afb4af)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 2 Chris King 2017-01-09 23:31:09 UTC
Anubhav, this does repro but is not a bug in Xamarin.Forms proper. As you can understand, we triage our bugzilla bugs to contain only bugzilla bugs so I'm gonna mark this invalid for now. 

That said, please have a look at 


I don't believe you've replicated this logic in your renderer. It's a sneaky little bit of logic. When dealing with XAML search-in-all-files is your friend! ;)

Feel free to re-open this bug if you still cannot find help on the forum and we'll do our best to help you after we drain the bugs from the core product.

Warm regards,