xaml - UserControl style only visible in designer -
i'd have page headers in app either icon or text centered in 50px high bar @ top of page. optionally back-button.
for reason use usercontrol on each page gets either 1 of styles applied: pageheaderstyle or pageheaderbackstyle.
my implementation of 1 of following (style definition in app.xaml):
<style x:key="pageheaderbasestyle" targettype="usercontrol"> <setter property="horizontalalignment" value="stretch" /> <setter property="verticalalignment" value="top" /> <setter property="height" value="50" /> <setter property="width" value="nan" /> <setter property="background" value="{staticresource cdcolor}" /> </style> <style x:key="pageheaderstyle" targettype="usercontrol" basedon="{staticresource pageheaderbasestyle}"> <setter property="content"> <setter.value> <grid background="{staticresource cdcolor}" horizontalalignment="stretch" verticalalignment="stretch" datacontext="{staticresource mainpagemodel}"> <textblock style="{staticresource pageheadertextblockstyle}" text="{binding title}" visibility="{binding titlevisibility}" /> <image style="{staticresource pageheadericonstyle}" source="{binding icon}" visibility="{binding iconvisibility}" /> </grid> </setter.value> </setter> </style> applied should be:
<usercontrol style="{staticresource pageheaderstyle}" /> now first had used "template" , applied datatemplate grid component. didn't work. changed directly set content of usercontrol. work: after building designer shows page header (before showed blue selection border, no content - transparent).
but start debugging app on emulator disappears , running app shows blank spot should be.
why so? mean after designer shows it, why disappear then, though?
fyi: not binding exceptions nor other. doesn't show up.
ps: tried setting background in base style while setting grid's background transparent. didn't work either - blank spot.
solved problem: best approach use contentcontrol. using content property did not work, though. have use contenttemplate property. using 1 work fine.
Comments
Post a Comment