I have a reference column and I want to make it readonly in the xamlDataGrid. How?
I have a xamdatadrid with many columns. For example, Name, Age, Location etc are the columns.
Name & Location are editable fields normally.
If Age is > 60, Name field should be readonly and Location will still editable for such records.How to make readonly columns at runtime based on values of other cell of a particular record? And if so, which method to hook - like InitializeRecord or sthg else?
Please clarify.
I have tried using this approach with a little bit of success. Just a couple of extra observations on this though:
1. Because you need to set AllowEdit to True for this solution, you will need to provide a dummy set accessor for the read only property. Without it, the behaviour seems to ignore the AllowEdit property and the event does not fire (as expected).
2. The <Shift>-<Tab> will not work as you tab back, the code imediately pushes you forward to where you came from.
It is a pitty that the xamDataGrid control does not affect the IsTabStop based the lack of a set accessor. It seems to for the AllowEdit side of things. I have tried using the KeyboardNavigation.IsTabStop property on the Filed without success.
Cheers, Baz.
Hello again,
As a workaround you can use the following:
Handle the EditModeStarted event like this:
private void xamDataGrid1_EditModeStarted(object sender, Infragistics.Windows.DataPresenter.Events.EditModeStartedEventArgs e) { if (e.Cell.Field.Name == "COLUMN_NAME") // check for cell by either ColumnName or index { xamDataGrid1.ExecuteCommand(DataPresenterCommands.CellNextByTab); e.Handled = true; } }
NOTE: You need the set to AllowEdit - True (not to false as suggested in the previous post) in order for the event to fire.
Hope this helps.Alex.
Hello Geoff,
I think that is not supported. If the XamEditor is embedded in the XamDataGrid the tab navigation cannot be modified. I will look for a possible workaround and if I find one I will post it here.
Alex.
That does the trick. But...
How about removing it from the tab stop. It would be nice not to stop on the field if it's readonly.
Thanks
Geoff