c# - Replace element in GridView on element's event -
i'm using highly dynamic gridview inside windows store app. element's inside gridview can have different template , size, depending on i'm inserting inside datasource. instance:
<gridview itemssource="{binding featured}" itemtemplate="{staticresource movieselectingtemplate}" itemspanel="{staticresource fluidmoviegriditemtemplate}" itemcontainerstyleselector="{staticresource variablesizedmoviestyleselector}" /> <datatemplate x:key="movieselectingtemplate"> <templateselectors:movietemplateselector content="{binding}" default="{staticresource defaultmovietemplate}" featured="{staticresource featuredmovietemplate}" ad="{staticresource admovietemplate}" horizontalalignment="stretch"/> </datatemplate> <itemspaneltemplate x:key="fluidmoviegriditemtemplate"> <variablesizedwrapgrid orientation="vertical" itemwidth="1" itemheight="1"/> </itemspaneltemplate> <local:featuredgridmoviestyleselector x:key="variablesizedmoviestyleselector" normalstyle="{staticresource normalmoviegridviewitemstyle}" adstyle="{staticresource admoviegridviewitemstyle}" featuredstyle="{staticresource featuredmoviegridviewitemstyle}"/>
app movies , can see can have 3 types of templates:
- normal movie template
- featured movie template (2x3 normal movies size)
- ad movie template - used scaffolding insert adds in grid (2x1 normal movie size)
movieselectingtemplate decides based on enum in movie class template use. when need insert ads in grid, create empty movie ad template. i've using microsoft pubcenter ads.
the problem is: pubcenter offering small quantity of ads, , replace element ad template when no ad, actual element. can know ad not available once grid datasource formed, it's hard replace inside. how can solve this?
upd:
<datatemplate x:name="admovietemplate"> <grid> <grid.background> <imagebrush imagesource="assets/logo-app-260x260.png" stretch="uniformtofill"/> </grid.background> <ui:adcontrol applicationid="{staticresource appid}" adunitid="{staticresource 250x250adunitid}" horizontalalignment="right" height="250" margin="0" verticalalignment="top" width="250" /> </grid> </datatemplate>
Comments
Post a Comment