.net - Exempt control in AdornerLayer from ViewBox stretching -


i have wpf control layed out this:

<viewbox stretch="uniform" name="viewboxname">     <itemscontrol>         <itemscontrol.itemtemplate>             <datatemplate>                 <!-- bunch of controls here want stretched in viewbox -->              </datatemplate>          </itemscontrol.itemtemplate>     </itemscontrol> </viewbox> 

then, in adornerlayer, have (using technique based on http://shevaspace.blogspot.com/2007/02/visual-level-programming-vs-logical.html) button control defined as

<button>     <image source="/acchimageload;component/icons/metrostudio/imagerotation.png" stretch="none" /> </button> 

how can button in adornerlayer use image's native resolution, instead of stretching viewbox?

basically, idea transform viewbox , apply inverse, binding converter.

the binding converter can inverse following code:

((containervisual)visualtreehelper .getchild((system.windows.dependencyobject)viewbox, 0)).transform.inverse 

in xaml, binding like

<button.layouttransform>     <multibinding converter="{bc:exemptfromviewboxtransformconverter}">        <binding source="{x:reference name=viewboxname}" />        <!-- actualwidth/actualheight bindings used ensure              transform updates when window resized. -->         <binding source="{x:reference name=viewboxname}" path="actualwidth" />         <binding source="{x:reference name=viewboxname}" path="actualheight" />     </multibinding> </button.layouttransform> 

see also:


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -