WPF Data Binding of Width Property -


i'm trying bind width property of canvas width property of shape instance. shape width should updated when canvas width gets new value

i want in code, without xaml, because create these elements on runtime.

i tried this, didnt work (the code inside of canvas):

binding binding = new binding(); binding.mode = bindingmode.onetime; binding.source = this; binding.path = new propertypath("width"); shape.setbinding(frameworkelement.widthproperty, binding); 

thanks lot help!

ksman

onetime looks wrong. think want use oneway or twoway. check the bindingmodes

edit

since oneway , actualwidth didn't fix problem, should recommend use tool debugging bindings. use snoop because free, there others. debugging wpf without tool can painful.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -