c# - How to apply different DataTemplate to a Listview -


in uwp app, have scenario in there multiple pages, constains listview display data, , each page have there own datatemplate base on content display, styling/colors of listview , datatemplate on each page same, problem whenever need change style inside datatemplate, setting border need go on each page that, how can make common ui data template different data display , assign listview, tried create usercontrol listview don't know how can pass datatemplate listview.

here's tried @ first level:

create user control , dependency property datatemplate: usercontrol cs file:

  public datatemplate displayitemtemplate     {         { return (datatemplate)getvalue(displayitemtemplateproperty); }         set { setvalue(displayitemtemplateproperty, value); }     }      public static readonly dependencyproperty displayitemtemplateproperty =             dependencyproperty.register("displayitemtemplate", typeof(datatemplate), typeof(listviewcontrol), new propertymetadata(null)); 

usercontrol xaml file:

 <listview x:name="displaylistview"                       isitemclickenabled="true"                       itemssource="{binding}"                       itemtemplate="{binding displayitemtemplate, mode=oneway}"                       itemcontainerstyle="{staticresourcelistviewitemexpandedstyle}"                       itemclick="displaylistview_itemclick"> 

peoplepage, using usercontrol:

  <controls:listviewcontrol x:name="mylistview"                               grid.row="1"                               displayitemtemplate="{staticresource mylistdatatemplate}" /> 

the issue mylistdatatemplate not getting set datatemplate in displaylistview.

<usercontrol x:name="usercontrol">  ... <listview x:name="displaylistview"                       isitemclickenabled="true"                       itemssource="{binding}"                       itemtemplate="{binding displayitemtemplate,elementname=usercontrol,mode=oneway}"                       itemcontainerstyle="{staticresourcelistviewitemexpandedstyle}"                       itemclick="displaylistview_itemclick"> ... </usercontrol> 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -