wpf - How do you bind a ContentTemplate directly to a Grid? -


in following xaml, trying bind various datatemplates directly grid contentpresenter. have put button inside grid prove myself contenttemplate binding , datatriggers working correctly - (note don't want type of control @ point). if replace <button> <contentpresenter> nothing shows up. i'm missing simple here.

      <datatemplate x:key="mytemplate">         <grid style="{staticresource gridallocatedstyle}">             <ellipse stroke="#ff5a71fb"                       strokethickness="0.5"                      style="{staticresource ellipsefinanciallyallocatedstyle}" />             <textblock style="{staticresource textblockinsideellipsestyle}"                         text="a"                        tooltip="allocated" />         </grid>     </datatemplate>       <datatemplate x:key="allocationtemplate">         <grid>                        <button> <!-- want bind grid.contentpresenter here -->                 <button.style>                     <style targettype="button">                                                      <style.triggers>                                                            <datatrigger binding="{binding allocated}" value="preallocatedboth">                                 <setter property="contenttemplate" value="{staticresource mytemplate}" />                             </datatrigger>                         </style.triggers>                     </style>                 </button.style>             </button>                     </grid>           </datatemplate> 

for completeness i'm trying achieve:

 <datatemplate x:key="allocationtemplate">         <grid>             <grid.style>                 <style targettype="grid">                                         <style.triggers>                         <datatrigger binding="{binding allocated}" value="none">                             <setter property="visibility" value="collapsed" />                         </datatrigger>                                            </style.triggers>                 </style>             </grid.style>             <contentpresenter> <!-- want bind grid.contentpresenter here -->                 <contentpresenter.style>                     <style targettype="contentpresenter">                                                      <style.triggers>                             <datatrigger binding="{binding allocated}" value="financiallyallocated">                                 <setter property="contenttemplate"  value="{staticresource mytemplate}" />                             </datatrigger>                                                                                   </style.triggers>                     </style>                 </contentpresenter.style>             </contentpresenter>                     </grid>           </datatemplate> 

maybe nothing shows because not have content set in contentpresenter?

p.s.: looks have lot of code doesn't relate issue (ellipse styles, many templates). takes while go through code, i'd ask remove unneeded code.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -