xaml - DataTemplate not found in merged ResourceDictionary -
i'm developing universal app windows phone 8.1 , windows 8.1. share of code, i'm willing keep style resources appart.
some context : first, right i've started wp8.1 projects related platform. in wp8.1 project, have mainpage.xaml contains pivot control. 1 of pivotitem usercontrol called, clarity purposes, myusercontrol.
i created resource dictionary styles.xaml "assets" directory, in both platform projects. then, registered 2 new files shared app.xaml :
<application.resources> <vm:viewmodellocator x:key="locator" d:isdatasource="true" /> <resourcedictionary x:key="resourcedictionary"> <resourcedictionary.mergeddictionaries> <resourcedictionary source="/assets/styles.xaml"></resourcedictionary> </resourcedictionary.mergeddictionaries> </resourcedictionary> </application.resources> in wp8.1 project styles.xaml file, created datatemplate :
<datatemplate x:key="mydatatemplate"> <textblock text="this textblock" /> </datatemplate> in myusercontrol, i've added listview , bound on itemtemplate property mydatatemplate :
<listview itemtemplate="{staticresource mydatatemplate}" itemssource="{binding mycontent}" /> when run solution , end error :
cannot find resource name/key "mydatatemplate" does know why encounter error ? did wrong ?
an odd thing : when right click > "go definition" on mydatatemplate bound in listview.itemtemplate property, routes me right place.
thank in advance !
your code wrong, here correct one
<application.resources> <resourcedictionary> <resourcedictionary.mergeddictionaries> <resourcedictionary source="/assets/styles.xaml"></resourcedictionary> </resourcedictionary.mergeddictionaries> <vm:viewmodellocator x:key="locator" d:isdatasource="true" /> </resourcedictionary> </application.resources>