Hello guys,
I am trying to write a custom control and my problem is that the column does not not receive DataContext and therefore cannot do the binding.
My custom control looks like this:
class customControl:ItemsControl
{
public ColumnCollection Columns { get; set; }
..
...
.....
}Code behind looks like this:
this.DataContext = new ViewModel()
class ViewModel { public list emplyee { get; set;} public string colName1 {get {return "hallo";}}
}
Column looks like this:
class Column : DependencyObject
{
public static DependencyPoperty Name = DependencyProperty.Register(.........);
public string Name
{
get { ..GetValue(...) }
set { ..SetValue(...) }
}
}And my XAML looks like this:
<customControl ItemsSource={Binding employees}><customcontrol.Columns><columnCollection><column name={Binding colName1}/></columnCollection></costumControl.Columns></customControl>Now the problem is that the column does not receive DataContext and cannot bind to the colName1 property which is in DataContext.
How do i solve this? How to pass down the DataContext to objects inside other objects inside other objects?