I need to style a subset of columns returned by a stored procedure that are dynamic i.e. certain column names will always be returned and have the same name and certain columns will vary based on what parameters were passed to the stored procedure. The style I want to apply is the width as well as change the font size and make the column read only or editable.
<igWPF:XamDataGrid.FieldLayouts> <igWPF:FieldLayout> <igWPF:FieldLayout.Fields>
<!-- THESE ARE STATIC COLUMNS -->
<igWPF:Field Name="valvegroup_log_ID" Visibility="Collapsed" /> <igWPF:Field Name="timeseq" Visibility="Collapsed" /> <igWPF:Field Name="cst" Visibility="Collapsed" /> <igWPF:Field Name="std_datetimeseq" Visibility="Collapsed" />
<igWPF:Field Name="Time" Label="Time" Width="50" />
<!-- HOW DO I APPLY A STYLE TO A SUBSET OF COLUMN WHOS QUANTITY AND NAME WILL VARY BASED ON PARAMETERS
PASSED TO STORED PROC? -->
</igWPF:FieldLayout.Fields> </igWPF:FieldLayout> </igWPF:XamDataGrid.FieldLayouts>
Thanks
Hi Kris,
Thank you for your reply. I am glad that you have managed to resolve your issue.
Actually I just figured it out.
In order to use Brushes.AliceBlue you need
using System.Windows.Media;
but I had
using Brushes = System.Drawing.Brushes;
when I commented using Brushes = System.Drawing.Brushes; out and just used using System.Windows.Media; it worked.
Well I'm not sure what to say. I can't reproduce the exception in your test project even when I setup the layout exactly like my project.
Hi,
Thank you for your reply. I was looking into your new issue and I was not able to reproduce any exception on my side using the provided code snippet.
I am attaching a sample application(DataGridFieldBrush.zip) that I used for my test.
Could you please try to reproduce your issue with my sample application?
Looking forward to hearing from you.
Thanks for pointing me in the right way. I decided to use OnFieldLayoutInitialized instead of OnFieldLayoutInitializing. I also have another question. I would like to set the background cell color for certain columns with the below code:
var cellValuePresenterStyle = new Style(typeof(CellValuePresenter)); var backgroundSetter = new Setter(BackgroundProperty, Brushes.AliceBlue); cellValuePresenterStyle.Setters.Add(backgroundSetter);
someField.Settings.CellValuePresenterStyle = cellValuePresenterStyle
but I'm getting the following exception:
System.Drawing.SolidBrush' is not a valid value for the 'System.Windows.Controls.Panel.Background' property on a Setter.
Any idea why?