Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want set the color to cell in the datagrid from based on the value of sql database.I typed below code and execute it will run but it dose not show any color in the cell.I did not find the solution to this problem.Help me please

What I have tried:

HTML
<DataGrid Name="dg">
            <datagrid.columns>
                <DataGridTextColumn Binding="{Binding Name}">
                <DataGridTextColumn Binding="{Binding Status}">
                    <datagridtextcolumn.elementstyle>
                       <Style.Triggers>
                         <Trigger Property="Text" Value="1">
                             <Setter Property="Background" Value="Blue"/>
                         </trigger>
                         <Trigger Property="Text" Value="2">
                             <Setter Property="Background" Value="Green"/>
                         </trigger>
                        </style.Triggers>
Posted
Updated 16-May-17 7:58am
v2
Comments
Michael_Davies 16-May-17 10:21am    
Do not know if case makes a difference but you have Triggers and /triggers and Style.Triggers with style.Triggers, every online example I looked at has them correctly cased and works.

1 solution

 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900