windows runtime - Declarative GridView in XAML in WinRT -


is there way define gridview purely declaratively in xaml? every example see defines category/group name value in code behind, each item has title / subtitle. figure out way following:

<gridview   x:name="itemgridview"   automationproperties.automationid="itemgridview"   automationproperties.name="grouped items"   grid.row="1"   margin="0,-3,0,0"   padding="116,0,40,46"   itemtemplate="{staticresource standard250x250itemtemplate}">    <gridview.itemspanel>     <itemspaneltemplate>                               <virtualizingstackpanel orientation="horizontal"/>     </itemspaneltemplate>   </gridview.itemspanel>    <gridview.groupstyle>     <groupstyle>       <groupstyle.headertemplate>         <datatemplate>           <grid margin="1,0,0,6">             <button               automationproperties.name="group title"               content="{binding tag}"               style="{staticresource textbuttonstyle}"/>           </grid>         </datatemplate>       </groupstyle.headertemplate>        <groupstyle.panel>         <itemspaneltemplate>           <variablesizedwrapgrid orientation="vertical" margin="0,0,80,0"/>         </itemspaneltemplate>       </groupstyle.panel>     </groupstyle>   </gridview.groupstyle>    <gridview.items>     <grid x:name="tab1" tag="tab 1" automationproperties.name="group title"    horizontalalignment="left" width="250" height="250">       <!-- tab content -->     </grid>      <grid x:name="tab2" tag="tab 2" automationproperties.name="tab 2" horizontalalignment="left" width="250" height="250">       <!-- tab content -->     </grid>   </gridview.items> </gridview> 

unfortunately example doesn't work. can't seem figure out how set group name declaratively. thank insights.

i think following method great way customize gridview.

*if implement multiple group style in grid, pls work:

step 1. create groupselector class , override selectstylecore function:

    public class groupstyleselector : styleselector     {     public style groupstyle1 { get; set; }     public style groupstyle2 { get; set; }      protected override windows.ui.xaml.style selectstylecore(object item, windows.ui.xaml.dependencyobject container)     {          var viewgroup = item icollectionviewgroup;         if (viewgroup != null)         {             //var groupmodel = viewgroup.group yourgroupmodel;             if (condition1)             {                 return groupstyle1;             }             else if (condition2)             {                 return groupstyle2;             }         }     } } 

step 2. in xaml resource, add these code:

<style x:key="yourgroupstyle1" targettype="groupitem">     <setter property="template">         <setter.value>             <controltemplate targettype="groupitem">                <!-- add custom layout here group style 1 -->             </controltemplate>         </setter.value>     </setter> </style>     <style x:key="yourgroupstyle2" targettype="groupitem">     <setter property="template">         <setter.value>             <controltemplate targettype="groupitem">                <!-- add custom layout here group style 1 -->             </controltemplate>         </setter.value>     </setter> </style>  <customstyle:groupstyleselector x:key="groupstyleselector"                               groupstyle1="{staticresource groupstyle1}"                               groupstyle2="{staticresource groupstyle2}"/> 

customstyle link namespace store groupstyleselector class.

step 3. apply style selector gridview control

if you want customize headertemplate pls let me know, if not user current gridapp sample microsoft.

if customize each item layout on group, simiar groupstyleselector: create datatemplateseletor (inherit templateselector) assign on gridview control

<gridview itemtemplateselector="{staticresource itemtemplateselector}">     <gridview.groupstyle>         <groupstyle containerstyleselector="{staticresource groupstyleselector}">             <groupstyle.headertemplate .../>     </gridview.groupstyle> 

hope guide clear you. if quesion, pls discuss.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -