Featured post
windows phone 7 - How to fill generated Pivot Elements with data [templates] -
howdy, generate in application several pivotitems in pivotelement. generation proceeding fine, don't know how can apply template pivot elements.
i thought need use:
pivotitem.contenttemplate = (datatemplate)ressources["kantinenuebersicht"];
but producing empty page.
my code in ressource file looks following:
inserted whole ressources file
<.resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<datatemplate x:key="kantinentemplate"> <stackpanel verticalalignment="top"> <textblock horizontalalignment="left" textwrapping="wrap" text="{binding name}" fontsize="{staticresource phonefontsizelarge}" margin="8,0,0,0" verticalalignment="top"/> <textblock horizontalalignment="left" textwrapping="wrap" text="{binding entfernung}" margin="24,0,0,0" fontsize="{staticresource phonefontsizesmall}" verticalalignment="bottom"/> </stackpanel> </datatemplate> <datatemplate x:key="kantinenuebersicht"> <grid> <textblock x:name="kantinenname" fontsize="{staticresource phonefontsizeextralarge}" text="" rendertransformorigin="0.566,0.407" margin="0,0,8,0" height="55" verticalalignment="top"> <textblock.foreground> <solidcolorbrush color="{staticresource phoneaccentcolor}"/> </textblock.foreground> </textblock> <textblock x:name="sdfsdf" horizontalalignment="left" height="40" margin="8,59,0,0" textwrapping="wrap" text="textblock" verticalalignment="top" width="196"/> <textblock x:name="lblgeoefsdfsdffnet" height="40" margin="208,59,8,0" textwrapping="wrap" text="textblock" verticalalignment="top"/> </grid> </datatemplate></resourcedictionary.>
had insert . in first tags...
what you're trying correct.
in question have "s" in "resources" issue.
if take code question, can add page:
<phone:phoneapplicationpage.resources> <datatemplate x:key="kantinenuebersicht"> <grid> <textblock x:name="kantinenname" fontsize="{staticresource phonefontsizeextralarge}" text="" rendertransformorigin="0.566,0.407" margin="0,0,8,0" height="55" verticalalignment="top"> <textblock.foreground> <solidcolorbrush color="{staticresource phoneaccentcolor}"/> </textblock.foreground> </textblock> <textblock x:name="lblentfernung" horizontalalignment="left" height="40" margin="8,59,0,0" textwrapping="wrap" text="textblock" verticalalignment="top" width="196"/> <textblock x:name="lblgeoeffnet" height="40" margin="208,59,8,0" textwrapping="wrap" text="textblock" verticalalignment="top"/> </grid> </datatemplate> </phone:phoneapplicationpage.resources>
and use when creating new item:
var newitem = new pivotitem { header = "added" }; newitem.contenttemplate = (datatemplate)resources["kantinenuebersicht"]; mypivot.items.add(newitem);
works on machine (emulator).
update:
if want add resource separate file can like:
resourcedictionary.xaml
:
<resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > <datatemplate x:key="kantinenuebersicht"> <grid> <textblock x:name="kantinenname" fontsize="{staticresource phonefontsizeextralarge}" text="" rendertransformorigin="0.566,0.407" margin="0,0,8,0" height="55" verticalalignment="top"> <textblock.foreground> <solidcolorbrush color="{staticresource phoneaccentcolor}"/> </textblock.foreground> </textblock> <textblock x:name="lblentfernung" horizontalalignment="left" height="40" margin="8,59,0,0" textwrapping="wrap" text="textblock" verticalalignment="top" width="196"/> <textblock x:name="lblgeoeffnet" height="40" margin="208,59,8,0" textwrapping="wrap" text="textblock" verticalalignment="top"/> </grid> </datatemplate> </resourcedictionary>
then must reference external file in page wishes use file.
<phone:phoneapplicationpage.resources> <resourcedictionary> <resourcedictionary.mergeddictionaries> <resourcedictionary source="\resourcedictionary.xaml"/> </resourcedictionary.mergeddictionaries> </resourcedictionary> </phone:phoneapplicationpage.resources>
- Get link
- X
- Other Apps
Comments
Post a Comment