Click here to Skip to main content
15,851,395 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi Experts,

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

In code

C++
SLDataGrid.ItemsSource=List<data></data>


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

ArunKumar
Posted
Updated 24-Mar-11 2:55am
v2

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?
http://dl.dropbox.com/u/3693471/DataGridExample.rar[^]
 
Share this answer
 
v2
Comments
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
Arun
XML
<u></u>this is for gridview, I need to do this for datagrid

there is no gv.Columns
 
Share this answer
 
hi Perry Bruins
i tried to download but i am not be able to download it.
can you send me in my mail id(ajayk@middlepathit.com)
thanks
ajay singh
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900