c# - Binding on a nested property without using XAML -


how make binding on nested target property, shape.stroke.color in wpf without using xaml ?

for simple property i'm using code looking :

var binding = new binding("mysourceproperty"); binding.source = mysourceobject; mytargetobject.setbinding(mytargetproperty, binding); 

where mytargetproperty can be, example, shape.strokeproperty. now, how can same thing on colorproperty of stroke of shape ?

provided shape's stroke property holds solidcolorbrush, can use static bindingoperations.setbinding method:

var shape = new path(); // or whatever var binding = new binding { source = colors.red }; // or whatever bindingoperations.setbinding(shape.stroke, solidcolorbrush.colorproperty, binding); 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -