Hi
I am having difficulty disabling in cell editing in the whole grid. What I am looking for is behavior similar to an old fashioned list view in the report view (ie click a row anywhere to select the whole row).
I have tried playing with the SelectionTypeRecord, SelectionTypeField and SelectionTypeCell properties but they have no effect. I know this can be achieved on a cell by cell basis but this seems a bit of an inefficient way of doing it. Does anyone know why the aforementioned properties have no effect or am I just missing something?
Also could someone point me at how the change the colour of cell text in C# from the codebehind, I am new to WPF but am I looking at altering a style?
Thanks
Alan
I apologize. The InitializeRecord fires when it is created (on load, grouped, ungouped, expanded). You should use the RecordsInViewChanged event for this.
I think I am using the default settings of the grid, what setting would stop the InitializeRecord from firing?
Using the Default settings of the XamDataGrid, the event should fire when scrolling no matter of the direction. If you have not so many records in the XamDataGrid, you can set the RecordContainerGenerationMode to PreLoad, which will disable the virtualization of the records.
If not, you can also use the RecordsInViewChanged event, which will fire when the records, that are currently in view change - in your scenario very close to InitializeRecord event.
Test these two options and let me know if you still have any problems.
Coming back on the text color I'm still having problems.
I need to set the text color of each row depending on a color supplied at run time by a field in the datasource. The color is set by the end user and can be anything. I have managed to get half way there using this code
private Style s;private Style s2;private Setter se;private Setter se2;private void xamDataGrid1_InitializeRecord(object sender, Infragistics.Windows.DataPresenter.Events.InitializeRecordEventArgs e){ //e.Record.DataPresenter.Background = Brushes.Red; DataRecord dr = e.Record as DataRecord;
if (dr != null) { if (((string)dr.Cells[5].Value).Trim() == "MR") { s = new Style(); se = new Setter(); se.Property = CellValuePresenter.ForegroundProperty; se.Value = Brushes.Red; s.Setters.Add(se); dr.Cells[5].Field.Settings.CellValuePresenterStyle = s; } else { s2 = new Style(); se2 = new Setter(); se2.Property = CellValuePresenter.ForegroundProperty; se2.Value = Brushes.Aquamarine; s2.Setters.Add(se2); dr.Cells[5].Field.Settings.CellValuePresenterStyle = s2; } } }
This kinda works when you scroll down the list but when you scroll back the event is no longer fired (I guess because of virtual loading) but all the items are re-rendered in aquamarine.
Any ideas please?
Once again thank you for your very helpful reply. I also wanted to stop cell editing on double click and also needed to set AllowEdit="False" in the FieldSettings object. Now it works great and I will be purchasing. I have to say that your product and support are far better than that of your main competitors.