Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to create a IList Dep property in DataGridTextColumn custom control and bind

$
0
0

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




Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>