Hai
I want create a Dependency property of IList in my custom control of datagrid .
My code is
public class DataGridListBoxColumn : DataGridTextColumn { public IList<Student> ListItems { get { return (IList<Student>)GetValue(_ListItems); } set { SetValue(_ListItems, value); } } public static readonly DependencyProperty _ListItems = DependencyProperty.Register("ListItems", typeof(IList<Student>), typeof(DataGridListBoxColumn)); }
In XAML of main window
<local:DataGridListBoxColumn Binding="{Binding M_Name,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" ListItems="{Binding Path= stud, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}" Width="100"/><!--<local:DataGridListBoxColumn Binding="{Binding M_Name,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" ListItems="{Binding RelativeSource={RelativeSource AncestorType=DataGridTextColumn}, Path=stud}" Width="100"/>--><!--<local:DataGridListBoxColumn Binding="{Binding M_Name,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" ListItems="{Binding stud, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGridTextColumn}}" Width="100"/>-->
I tried above 3 method , but I am not getting my list inside my UC. Please help how to bind this.
Thanks
programmer