Click here to Skip to main content
12,951,606 members (59,663 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi Experts,

I have a Silverlight DataGrid and, it is binded with a dataSource.
<data:DataGrid x:Name="SLDataGrid" RowStyle="{StaticResource MyDataGridRowStyle}"  

In code


Fine.. Now based on the value of "Data.IsReadOnly"(IsReadOnly is a Boolean Field), How I can set those particular Rows as ReadOnly in Silverlight DataGrid.

Thanks and Regards

Posted 24-Mar-11 1:18am
Updated 24-Mar-11 1:55am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

It is not possible to set entire rows to readonly in a datagrid. You can however set the control containing your datavalue to readonly; just bind the ReadOnly property to your rowvalue's readonly property.

[edit] hmm, I do not seem to be able to attach the zip file with the solution in it, can you download it from here?[^]
Arun India 25-Mar-11 2:29am
Thanks Perry Bruins for your reply. But Perry Bruins, we are defining only columns in Silverlight datagrid. We can make that columns as readonly no problem. But how it is possible in the case of only certain rows..??(Since we are binding Datagrid with some item source).
Perry Bruins 25-Mar-11 6:53am
Hi Arun India,

The datagrid builds the row based upon the control definition used for that column. Any binding to the template for that control will be applied for each row.

So, you must use the template form of the column definition in order to be able to specifiy which control you will be using. Part of that template will then be also the binding to your readonly property.
Arun India 25-Mar-11 8:48am
Hi Perry Bruins,
That means we can make a column(Controls like TextBlock, CheckBox etc.) as Read only, not the row.. right...??
Perry Bruins 25-Mar-11 14:34pm
Hi Arun India,

well, what happens is that during binding of your datasource, for each row, the template definition of the column is used to create the control that shows your data for each column. At that time, it will also use the binding of the readonly flag. I have no example handy right now, but if you really need it, I can try to put up one during the weekend.
Arun India 26-Mar-11 6:49am
Thank you very much Perry Bruins for you valuable time. It will be very helpful for me, if you put the example.. Once again Thanks for your valuable answer.

Good Luck
Perry Bruins 26-Mar-11 10:41am
Here is the example. Note the usage of the template columns in XAML, specially the binding to the IsEnabled property of the controls. Hope this helps you enough.

I do not seem to be able to attach the solution zip, here is a public download link to it. Hope this helps!
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

<u></u>this is for gridview, I need to do this for datagrid
there is no gv.Columns
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

hi Perry Bruins
i tried to download but i am not be able to download it.
can you send me in my mail id(
ajay singh

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,229
CHill60 3,490
Maciej Los 3,083
Jochen Arndt 1,975
ppolymorphe 1,880

Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 11 Jan 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100