WPF - Programmatic Binding on a BitmapEffect -


i able programmatically bind data dependency properties on bitmapeffect. frameworkelement textblock there setbinding method can programmatically these bindings like:

mytextblock.setbinding(textblock.textproperty, new binding("someproperty")); 

and know can in straight xaml (as seen below)

<textblock width="auto" text="some content" x:name="mytextblock" textwrapping="wrap" >     <textblock.bitmapeffect>         <bitmapeffectgroup>             <outerglowbitmapeffect x:name="myglow" glowcolor="white" glowsize="{binding path=myvalue}" />         </bitmapeffectgroup>     </textblock.bitmapeffect> </textblock> 

but can't figure out how accomplish c# because bitmapeffect doesn't have setbinding method.

i've tried:

mytextblock.setbinding(outerglowbitmapeffect.glowsize, new binding("someproperty") { source = someobject }); 

but doesn't work.

you can use bindingoperation.setbinding:

binding newbinding = new binding(); newbinding.elementname = "someobject"; newbinding.path = new propertypath(someobjecttype.someproperty); bindingoperations.setbinding(myglow, outerglowbitmapeffect.glowsizeproperty, newbinding); 

i think should want.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -