c# - Binding a DataGridColumn to a property in the containing UserControl -
i want bind custom datagridboundcolumn
property in containing usercontrol
. property contains information tells column how generate content.
this seemed easy @ first, data context in data grid changed, , can't seem reference containing user control. here tried:
elementname
doesn't work, since column isn't in same name scope.- using
x:reference
, has worked me in similar situations, gives initialization error. - using
findancestor
doesn't work, since column isn't part of same visual tree. - the column doesn't seem have property such
owner
gets containingdatagrid
.
i can think of few ways solve problem, , they're messy or unsatisfactory:
- trying find reference through code in column. goes against point of having column, reusing in few different contexts.
- create static resource
dummy
dependency propertyvalue
bound user control usingx:reference
extension, , bind column static resource, finding required property usingpath
. this i'm doing now
Comments
Post a Comment