WPF - Freezable in a style of a button not inheriting DataContext -


i modeling attached command pattern after attachedcommandbehavior library here. button looks this:

<button>     <button.style>         <style targettype="{x:type button}">             <setter property="vms:attached.behaviors">                 <setter.value>                     <vms:behaviors>                         <vms:behavior event="click"                                        command="{binding clickcommand}" />                     </vms:behaviors>                 </setter.value>             </setter>         </style>     </button.style> </button> 

everything works great, when setter on behavior executed, command null.

behavior freezable, , behaviors freezablecollection<behavior>. doesn't seem inheriting datacontext button.

on other hand, works correctly:

<button>     <vms:attached.behaviors>         <vms:behavior event="click" command="{binding clickcommand}" />     </vms:attached.behaviors> </button> 

unfortunately can't way, because need target generated listviewitems using itemcontainerstyle.

is there way datacontext in style?

the attached command behavior library germ of idea became blend behaviors. blend behaviors more powerful , standardized , recommend switch using them. whether using attached command behavior or blend behaviors, problem essential same: don't work expected when trying set them using style. i've solved problem blend behaviors full support binding in stackoverflow answer:

without testing it, guess have move acb behavior resource marked x:shared="false" in order binding work.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -