Hi @all,
we start working with the XAML-Controls from Infragistics for creating Windows 8.1/RT-Apps and are quite impressed by the XamGrid. Maybe a quite simple question, but I don't find any option to set properly.
In UltraWinGrid (Windows.Forms), there was an option CellClickAction which could be set to RowSelect. In our App the user should be able to say how the grids react on CellClick (e.g. RowSelect, CellSelect, ColumnSelect). The info is saved in the database. So I need a possiblity to programmatically set the option in the C# code behind. How can I do this? I cannot find anyhing...
Additionally I observed that all rows with an odd rownumber have a light gray background the rows with an even number a white one (or the other way round). That's nice. but the gray background is not spread over the complete row, but only as background of the values. Can this also be changed the way, that the background is over the complete row including empty cells (how? possible also in C# code for customizing the app?)?
We use version 13.2.0.0.
Thank you.
Best regards
Alex
For the second point I observed the problem (concerning the gray bakground of rows).
The grid is in a hubsection and is filled, formatted, translated and filtered (as in the Database declared) in the Loaded-Event of the XamGrid.This seems to be the problem. All grids handeled this way show this strange behaviour. (grid.RowHover also does not mark the complete row but only the text in the cells).
Any ideas?
Hi Alex,
XamGrid has a SelectionSettings property, which is basically a container of all selection related settings you could apply. For example on the SlectionSettings Object you'll find a CellClickAction property with possible values SelectCell and SelectRow. As for the column selection there is a separate property ColumSelection prop where you could specify column selection type - Multiple|Single|None.
For other selection options you could check out the selection help page
As for your second question - I was not able to reproduce such a behavior where the Alternating Row Background I was not able to reproduce such a behavior where the they are applied only over a cell with value. I've attached the sample app a used to try to reproduce it. Could you modify it so I could investigate this in detail.
Hi,
thank you for your answer.
First point is clear now and solved :-)
For the second point I do not see any atachment..
Sorry Alex,
I must have forgotten to actually attach it :)
Find the solution attached here.
you are great! Works perfectly!
Thank you very much.
Beste regards
HorizontalContentAlignment property of the CellControl class is being used internally(and set local value that is overriding the style value) and the HorizontalAlignmet is causing the issues observed on your screenshot - you're changing it from Stretch to Right wich makes the CellControl not to occupy the horizontal space that is being allocated for the cell.
To achieve your goal you need to set the Column.HorizontalContentAlignment property so your FormatGrid method would looks this:
private void FormatGrid() { foreach (ColumnBase col in xamGrid.Columns) { var column = col as Column; if(column != null) { Type typ = col.DataType; if (typ == typeof(int) || typ == typeof(long) || typ == typeof(decimal) || typ == typeof(float)) { column.HorizontalContentAlignment = HorizontalAlignment.Right; } else { column.HorizontalContentAlignment = HorizontalAlignment.Left; } } } }
Hope that helps,
the problem in my code is localized.I wrote an own usercontrol inheriting from the XamGrid. This automatically formats the grid when data is bound to it (numbers are aligned right, the rest left). I do it this way:
private void FormatGrid() { foreach (ColumnBase col in this.Columns) { Type typ = col.DataType; if (typ == typeof(int) || typ == typeof(long) || typ == typeof(decimal) || typ == typeof(float)) { Style s = new Style(typeof(Infragistics.Controls.Grids.CellControl)); s.Setters.Add(new Setter(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Right)); s.Setters.Add(new Setter(Control.HorizontalContentAlignmentProperty, HorizontalAlignment.Right)); col.CellStyle = s; } else { Style s = new Style(typeof(Infragistics.Controls.Grids.CellControl)); s.Setters.Add(new Setter(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Left)); s.Setters.Add(new Setter(Control.HorizontalContentAlignmentProperty, HorizontalAlignment.Left)); col.CellStyle = s; } } }
attached please find the result of this formatting. Without the formatting everything is fine. Is there another solution to format this correctly in C# code? This alignment will also be customizable by the user in the final version of the app.
Thank you!