views:

34

answers:

1

Is there a way to make column of cells in a Silverlight datagrid be readonly in editmode with C# code instead of setting up a entire datagrid as a template in a resource file?

UPDATE
Found an example piece of code - http://forums.silverlight.net/forums/p/17483/58189.aspx

In the response by slhungry midway into the thread. He has example code written as a XAML template. Can you write this in C#?

+1  A: 

Well, you can certainly create DataGridColumns programmatically in your codebehind and add them to your DataGrid:

DataGridColumn myColumn = new DataGridColumn();

Then you can easily configure the properties:

myColumn.Header = "tyndall's New Column";

myColumn.IsReadOnly = true; // All cells in column will be readonly

You can also programmatically set up binding in the codebehind, if you wish. Finally, you can add this column to the datagrid:

myDataGrid.Columns.Add(myColumn);

Does this help answer your question?

Donut
What if you wanted to make the text selectable but take away the edit mode basically. Don't you just have to put it in ReadOnly while in Edit Mode. I'm having trouble finding the snippet I saw online with the XAML template code. I'll continue to look for it
tyndall
see UPDATE to question
tyndall