Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
300
Set Foreground color of cells
posted

Hello,

 

I have some cells I want to mark if they have particular values. I have taken a look at the example but I am no able to fully grasp this and use it for my project. The problem is, that I don't set any fields in xaml but dynamically in the code. I tried to just use the InitializeRecord-Event and set the style "by hand", but this does not work:

 

void EvaluationList_InitializeRecord(object sender, Infragistics.Windows.DataPresenter.Events.InitializeRecordEventArgs e)
        {
            if (e.Record is DataRecord)
            {
                if (typeOfData == "A" || typeOfData == "B")
            {
                if (Convert.ToInt32(e.Record.Cells[FieldNames.NOLTL].Value) > 0)
                {
                    e.Record.Cells[FieldNames.LTL].Field.Settings.CellValuePresenterStyle = this.ViolationsCellStyle;
                }
            }
            }
        }

The ViolationsCellStyle is set in the xaml resource:

        <DockPanel.Resources>           
            <Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="violationsFieldStyle">
                <Setter Property="Foreground">
                    <Setter.Value>
                        <SolidColorBrush Color="Red" />
                    </Setter.Value>
                </Setter>
            </Style>
        </DockPanel.Resources>

I hope you can tell me what I am doing wrong here.

I am using v.10.1.