xaml - x:Bind in resource dictionary doesn't work -


i'm struggling grip of compiled databinding concept. have 1 view (mainpage) contains listbox , 1 data template (itemtemplate) used listbox. mainpage has mainpageviewmodel contains observablecollection of itemviewmodels. itemviewmodel contains 1 property name.

mainpage:

<page x:class="testapp.mainpage"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     xmlns:local="using:testapp">     <page.resources>         <resourcedictionary>             <resourcedictionary.mergeddictionaries>                 <resourcedictionary source="itemdictionary.xaml" />             </resourcedictionary.mergeddictionaries>         </resourcedictionary>     </page.resources>      <grid background="{themeresource applicationpagebackgroundthemebrush}">         <listbox itemssource="{x:bind viewmodel.items}"                  itemtemplate="{staticresource itemtemplate}" />     </grid> </page> 

resource dictionary containing datatemplate:

<resourcedictionary     x:class="testapp.itemdictionary"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     xmlns:local="using:testapp">      <datatemplate x:key="itemtemplate" x:datatype="local:itemviewmodel">         <textblock text="{x:bind name}" />     </datatemplate>     </resourcedictionary> 

this code compiles when run binding name property fails, although items generated. if use classic binding works fine , if place data template directly in resources mainpage works. missing?

correct:

<page.resources>     <resourcedictionary>         <resourcedictionary.mergeddictionaries>             <local:itemdictionary />         </resourcedictionary.mergeddictionaries>     </resourcedictionary> </page.resources> 

incorrect:

<page.resources>     <resourcedictionary>         <resourcedictionary.mergeddictionaries>             <resourcedictionary source="itemdictionary.xaml" />         </resourcedictionary.mergeddictionaries>     </resourcedictionary> </page.resources> 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -