c# - Why doesn't my style get set on the child of a ContentControl in WPF -


i have following xaml code wpf

    <contentcontrol>         <contentcontrol.resources>             <style targettype="selections:entityselector">                 <setter                      property="entityselectormanager"                      value="{binding  selectormanager, mode=oneway }"/>             </style>         </contentcontrol.resources>         <contentcontrol.content>             <binding path="editor" />         </contentcontrol.content>     </contentcontrol> 

then in code behind in response event have set editor propety

    this.editor = element 

where element control contains 1 or more entityselector objects. once control instantiated in visual tree can see binding has not worked.

first check selectormanager property on datacontext @ level of contentcontrol. seems in order

enter image description here

now go contentcontrol , see if of entityselector controls have entityselectormanager properties set.

enter image description here

you can see there binding expression result null. why this?

i have solution don't it. using dynamic resource initialized codebehind

public weincamwindow(weincamworkpiece camviewmodel) {     viewmodel = camviewmodel;     initializecomponent();     datacontext = viewmodel;     this.resources["entityselectionmanager"] = viewmodel.selectormanager;  } 

and in style use dynamic resource

<style targettype="selections:entityselector">     <!-- 'entityselectionmanager' set in code behind. -->     <setter property="entityselectormanager"             value="{dynamicresource entityselectionmanager}" /> </style> 

the dyamic resource propogates other tricks tried didn't work.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -