c# - Sort a Custom DataGridColumn in WPF -


i have custom datagridcolumn created facilitate animation. before updated column column sortable (provided framework), mark-up below

 <controls:resourcedatagrid x:name="resourcedatagrid"                              horizontalalignment="stretch"                              verticalalignment="stretch"                              autogeneratecolumns="false"                              gridlinesvisibility="none"                             rowheaderwidth="0"                              canuseraddrows="true"                              canuserdeleterows="true"                              itemssource="{binding path=resources,                                                    mode=twoway,                                                   updatesourcetrigger=propertychanged,                                                    isasync=true}"                              dataaccess:datagridtextsearch.searchvalue="{binding elementname=searchbox,                                                                                  path=text,                                                                                  updatesourcetrigger=propertychanged}"                              dataaccess:datagridtextsearch.isanytextmatch="false">     <controls:resourcedatagrid.columns>         <!--<datagridtemplatecolumn celltemplate="{staticresource readonlycellupdatedstyle}"  isreadonly="true"/>-->         <datagridtextcolumn header="keyindex" binding="{binding keyindex}" isreadonly="true"/>         <datagridtextcolumn header="filename" binding="{binding filename}" isreadonly="true"/>         <datagridtextcolumn header="resourcename" binding="{binding resourcename}" isreadonly="false"/>      <controls:collectiontextcolumn collection="resourcestringlist" visibility="collapsed"/> </controls:resourcedatagrid.columns> 

the new column shown above commented , prevents column being sortable. code datagridtemplatecolumn below

<datatemplate x:key="readonlycellupdatedstyle">     <textblock text="{binding keyindex,                                notifyontargetupdated=true,                                mode=twoway}">         <textblock.style>             <style targettype="textblock">                 <setter property="background" value="transparent"/>                 <style.triggers>                     <eventtrigger routedevent="binding.targetupdated">                         <beginstoryboard>                             <storyboard>                                 <coloranimation storyboard.targetproperty="background.color" duration="0:0:1.5"                                                 from="transparent" to="orange" repeatbehavior="1x"                                                  autoreverse="true">                                     <coloranimation.easingfunction>                                         <exponentialease easingmode="easeinout"/>                                     </coloranimation.easingfunction>                                 </coloranimation>                             </storyboard>                         </beginstoryboard>                     </eventtrigger>                 </style.triggers>             </style>         </textblock.style>     </textblock> </datatemplate> 

how can make datagridtemplatecolumn sortable?

thanks time.

you need set sortmemberpath on datagridtemplatecolumn

maybe try:

  <datagridtemplatecolumn sortmemberpath="keyindex" celltemplate="{staticresource readonlycellupdatedstyle}"  isreadonly="true"/> 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -