i am to implement the style via code behind. i am able to create styles thru code behind.
my question is how can i create nested styles of xamdatagrid's DataRecordCellArea styles. for e.g ForegroundAlternateStyle.
what i found in generic themes of xamdatagrid.
how can i write this via code behind.
<!-- _________________________ BlackForegroundStyle ______________________________________ --> <Style x:Key="{ComponentResourceKey {x:Type igDP:XamDataGrid}, GrayForegroundStyle}"> <Setter Property="TextBlock.Foreground" Value="#FF333333" /> </Style>
here is how i m implementing
void ApplyRecordAreaStyle() { Style recordstyle = new Style(typeof(DataRecordCellArea)); recordstyle.Setters.Add(new Setter(DataRecordCellArea.BackgroundAlternateProperty, SelectedBackground)); recordstyle.Setters.Add(new Setter (DataRecordCellArea.ForegroundAlternateStyleProperty ,????????)); xamGrid.FieldLayoutSettings.DataRecordCellAreaStyle = recordstyle; }
Hello,
Thank you for your post. I have been looking into it and you can create a style for the ContentPresenter and use it as a value for the setter for the ForegroundAlternateStyle property. Also if you wish to change the foreground of the alternated records I can suggest adding a Trigger to the style for the DataRecordCellArea for the IsAlternated property. Here is how you can implement the approach that I have mentioned:
void ApplyRecordAreaStyle() { Style recordstyle = new Style(typeof(DataRecordCellArea)); recordstyle.Setters.Add(new Setter(DataRecordCellArea.BackgroundAlternateProperty, Brushes.Yellow)); Style foregroundStyle = new Style(typeof(ContentPresenter)); foregroundStyle.Setters.Add(new Setter(ContentPresenter.OpacityProperty, .7)); recordstyle.Setters.Add( new Setter (DataRecordCellArea.ForegroundAlternateStyleProperty, foregroundStyle)); //Trigger for setting the foreground for the alternated records Trigger trigger = new Trigger { Property = DataRecordCellArea.IsAlternateProperty, Value = true }; trigger.Setters.Add(new Setter(DataRecordCellArea.ForegroundProperty, Brushes.Red)); recordstyle.Triggers.Add(trigger); xamGrid.FieldLayoutSettings.DataRecordCellAreaStyle = recordstyle; }
In you need any further assistance on the matter please do not hesitate to ask.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
I am just checking if you require any further assistance on the matter.
Thank you for your feedback. I am very glad that the approach I have suggested helped solving your issue. If you need any further assistance on the matter, please do not hesitate to ask.
Thanks for the help.