Click here to Skip to main content
11,642,233 members (61,109 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Silverlight
Hi Experts,

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

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 24-Mar-11 1:18am
Edited 24-Mar-11 1:55am
v2
Rate this: bad
good
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?
http://dl.dropbox.com/u/3693471/DataGridExample.rar[^]
  Permalink  
v2
Comments
Arun India at 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 at 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 at 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 at 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 at 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
Perry Bruins at 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!

http://dl.dropbox.com/u/3693471/DataGridExample.rar
Rate this: bad
good
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
  Permalink  
Rate this: bad
good
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(ajayk@middlepathit.com)
thanks
ajay singh
  Permalink  

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



Advertise | Privacy | Mobile
Web04 | 2.8.150731.1 | Last Updated 11 Jan 2012
Copyright © CodeProject, 1999-2015
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