tags:

views:

33

answers:

1

hello all

i have a problem i m making a wpf application and using data grid Control to Show tabular data i m adding a Single Coloum in data Grid through Xaml And My All Other Column Would be add Dynamic my Fixed Column Comes At first postion in Grid i Want to be it to be come At last

how can i achive it

my Xaml code is As below

Thanks in Advance shashank`

            <my:DataGrid.Columns>
                <my:DataGridTemplateColumn Header="Edit" Width="110" IsReadOnly="True" >
                    <my:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Image Source="file:///D:\Projects\ChadCarpenter\AARFID\AARFID\Images\boardicon.png" />
                        </DataTemplate>
                   </my:DataGridTemplateColumn.CellTemplate> 
                    </my:DataGridTemplateColumn> 
           </my:DataGrid.Columns>

And below are my C #` public void CreateDataTableheader() {

        if (Utility.CheckGroupFamily == "Group")
        {
            dtAdultinfo.Columns.Add("Group Name", typeof(String));
        }
        dtAdultinfo.Columns.Add("Last Name", typeof(String));
        dtAdultinfo.Columns.Add("First Name", typeof(String));
        dtAdultinfo.Columns.Add("Phone", typeof(String));
        dtAdultinfo.Columns.Add("CellPhone", typeof(String));
        dtAdultinfo.Columns.Add("TowerID", typeof(String));
        dtAdultinfo.Columns.Add("Room #", typeof(String));
        dtAdultinfo.Columns.Add("IS primary", typeof(int));

        Lst.ItemsSource = dtAdultinfo.DefaultView;

        //DataGridColumn dc;
        //DataGridTemplateColumn  dgColumn = new DataGridTemplateColumn();

        //DataTemplate dt = new DataTemplate();

        //dgColumn.Header="Edit";
        //dgColumn.Width = 110;
        //dgColumn.IsReadOnly= true;


        //dgColumn.CellTemplate = dt;
        //Image img = new Image();
        //BitmapImage logo=new BitmapImage();

        //logo.UriSource =new Uri("file:///D:/Projects/ChadCarpenter/AARFID/AARFID/Images/boardicon.png");


        DataGridTemplateColumn dgColumn = new DataGridTemplateColumn();
        dgColumn.Header = "Edit";
        FrameworkElementFactory factory1 = new FrameworkElementFactory(typeof(Image));
        Binding b1 = new Binding("Picture");
        b1.Mode = BindingMode.TwoWay;
        factory1.SetValue(Image.SourceProperty, b1);
        DataTemplate cellTemplate1 = new DataTemplate();
        cellTemplate1.VisualTree = factory1;
        dgColumn.CellTemplate = cellTemplate1;
        Lst.Columns.Add(dgColumn);`
+1  A: 

Check this link which talks about DatagridColumn.DisplayIndex property. This is used to change the column display order in the datagrid. Hope this might help you -

http://msdn.microsoft.com/en-us/library/system.windows.controls.datagridcolumn.displayindex.aspx

Sachin Shanbhag