.NET Framework Bookmark and Share   
 index > Windows Presentation Foundation (WPF) > Changing color according to value ?
 

Changing color according to value ?

Dear all,

I am new in using WPF , just start to study what I can do with it. But my main interest is mainly to convert my old style project interface to WPF and impressmy customer.

One feature of my old interface was the possibility to change the color of a symbole in a list according to a status of a particular database field.

For example, let say that I have display a datgrid whcih is bind to a dataset which represent an alarm collection in form as follow:

SeverityMachine name Description Time

1 Hopper No more Material 12:20:2005

4 Hopper Power fault 12:40:2005

8 Hopper No more Material 12:55:2005

Then in my Datagrid I ma displaying the secerity in different form :

  • The full row is display as Red background when Severity fiedl=1
  • I can also display a red symbol for the same criteria

What si the way to do this with WPF and Blend

regards

Thanks for help

Serge

http://wakespirit.spaces.live.com/

Serge Calderara

re

Here you have 2 links on how to bind (the first one with xml and the second with sql) :

++

PlaTyPuS8

you can do it with DataTriggers

something like that :

Code Snippet

<DataTrigger Binding="{Binding Path=field}" Value="1">

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

</DataTrigger>

++

PlaTyPuS8

Hello,

Thnaks for your reply but I am a bit lost in here.

I have create a WPF project under Visual studio . I have place on a windows form a grid control that I would like to bind with a dataset. My code is as follow :

Dim sqlCon As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(con)

Dim sadapter As New System.Data.SqlClient.SqlDataAdapter

Dim cmd As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand

cmd.Connection = sqlCon

cmd.CommandText = "SELECT * FROM Event"

cmd.CommandType = System.Data.CommandType.Text

sadapter.SelectCommand = cmd

sadapter.Fill(ds, "Event")

How to bind the dataset (ds) ?

Does this ds variable is directly visible from Blend ? I guess not

regards

serge

Serge Calderara

re

Here you have 2 links on how to bind (the first one with xml and the second with sql) :

++

PlaTyPuS8

You can use google to search for other answers

Custom Search

More Threads

• June CTP TreeView.ItemsSource no longer works with IEnumerable. Bug?
• Panel SetZIndex issue
• Accessibility
• Click on Hyperlink: null reference exception!
• Dec CTP
• How to Change Image Source Property at runtime
• Replacement for TextFlow
• Control -> Geometry
• binding colorpicker
• Report Viewer Control