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:

  1. elementname doesn't work, since column isn't in same name scope.
  2. using x:reference, has worked me in similar situations, gives initialization error.
  3. using findancestor doesn't work, since column isn't part of same visual tree.
  4. the column doesn't seem have property such owner gets containing datagrid.

i can think of few ways solve problem, , they're messy or unsatisfactory:

  1. trying find reference through code in column. goes against point of having column, reusing in few different contexts.
  2. create static resource dummy dependency property value bound user control using x:reference extension, , bind column static resource, finding required property using path. this i'm doing now


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -