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
505
How to apply Foreground Color for Disable (IsEnabled=False) Records in xamdatagrid
posted

How to apply Foreground  Color for Disable (IsEnabled=False) Records in xamdatagrid

 

I am using following code is enabled working fine but  foreground color not applied for records

<igDP:XamDataGrid Name="XamDataGridSqlViews" GroupByAreaLocation="None" IsSynchronizedWithCurrentItem="True">

                           

<igDP:XamDataGrid.Resources>

                               

<Style TargetType="{x:Type igDP:CellValuePresenter}">

                                   

<Setter Property="BorderThickness" Value="1,0,1,1"/>

                                   

<Setter Property="BorderBrush" Value="LightGray"/>

                               

</Style>

                               

<Style TargetType="{x:Type igDP:DataRecordCellArea}">

                                   

<Setter Property="Background" Value="White"/>

                                   

<Setter Property="Foreground"   Value="Black" />

                                   

<Setter Property="BackgroundHover" Value="AliceBlue"/>

                                   

<Style.Triggers>

                                      

<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Record.DataItem.IsMandatory}" Value="True">

                                           

<Setter Property="IsEnabled"  Value="False" />

                                       

</DataTrigger>

                                       

                                       

<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Record.DataItem.IsMandatory}" Value="True">

                                           

<Setter Property="Foreground" Value="Red"/>

                                       

</DataTrigger>

                                      

                                   

</Style.Triggers>

                                  

 

                               

</Style>

                

</igDP:XamDataGrid.Resources>

 

</igDP:XamDataGrid>

Parents
No Data
Reply
  • 138253
    Offline posted

    Hello Koteswara,

     

    Thank you for your post. I have been looking into it and I can say that when you set the DataRecordCellArea’s IsEnabled Property to false, the style that is applied overrides the Foreground. In order to set the foreground to a color you want you should create a Style for the Editor that is inside the CellValuePresenter and add a similar Trigger. I created a sample project for you showing how to do so. I can also say that you should create similar Style for all kind of Editors that your XamDataGrid will use, in my case this is only XamNumericEditor. Please let me know if this helps you or you need further assistance on this matter.

     

    Looking forward for your reply.

    XamDataGridForeground.zip
Children