tabcontrol - WPF findancestor not working on second tabitem -


quite simple problem (i think!) can't seem find simple answer it.

i've build test wpf app contains tabcontrol , 2 tab items. on each tabitem button , it's content bound path stored in local resource dictionary. path's fill property bound button's foreground property using findancestor.

the problem: on tab1 content displays correctly on tab2 doesn't display @ all. if remove findancestor binding , replace brush (say, white), both buttons display correctly.

i'm hoping i'm missing simple because seems should possible.

code:

<window.resources>     <resourcedictionary>         <path x:key="tickicon2" fill="{binding foreground, relativesource={relativesource findancestor, ancestortype={x:type control}}}" stretch="uniform" x:shared="false"  data="f1 m 23.7501,33.25l 34.8334,44.3333l 52.2499,22.1668l 56.9999,26.9168l 34.8334,53.8333l 19.0001,38l 23.7501,33.25 z"/>     </resourcedictionary> </window.resources> <grid>     <tabcontrol>         <tabitem header="1">             <button content="{dynamicresource tickicon2}"  width="50" height="50" />         </tabitem>         <tabitem header="2">             <button  content="{dynamicresource tickicon2}"  width="50" height="50" />         </tabitem>     </tabcontrol> </grid> 

most has shared (default) nature of resources in resource dictionary.

read: msdn.

you can try making resource not shared (x:shared=false)

<path x:key="tickicon2" x:shared="false" fill="{binding foreground, relativesource={relativesource findancestor, ancestortype={x:type control}}}" stretch="uniform" x:shared="false"  data="f1 m 23.7501,33.25l 34.8334,44.3333l 52.2499,22.1668l 56.9999,26.9168l 34.8334,53.8333l 19.0001,38l 23.7501,33.25 z"/> 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -