Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. change color of Datagrid text

change color of Datagrid text

Scheduled Pinned Locked Moved WPF
databasehelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    picasso2
    wrote on last edited by
    #1

    Hello members, I have tables (DBTable) in SQL 2008 that contains two columns that look like this: Col1 Col2 0 1 0 1 1 1 1 1 0 1 I created a Silverlight application (BI -RIA and domain services) that populates the datagrid as follows MyCarsDomainContext context = new MyCarsDomainContext(); dataGrid1.ItemsSource = context.DBTables; context.Load(context.GetDBTablesCompareQuery()); I would like to change the row background color (just the text color will work fine too) based on the value of Col1. If 0 then row is red, if 1 then row is blue Any help is greatly appreciated

    A A 2 Replies Last reply
    0
    • P picasso2

      Hello members, I have tables (DBTable) in SQL 2008 that contains two columns that look like this: Col1 Col2 0 1 0 1 1 1 1 1 0 1 I created a Silverlight application (BI -RIA and domain services) that populates the datagrid as follows MyCarsDomainContext context = new MyCarsDomainContext(); dataGrid1.ItemsSource = context.DBTables; context.Load(context.GetDBTablesCompareQuery()); I would like to change the row background color (just the text color will work fine too) based on the value of Col1. If 0 then row is red, if 1 then row is blue Any help is greatly appreciated

      A Offline
      A Offline
      AbhijeetB
      wrote on last edited by
      #2

      Use DataGridTemplateColumn and use Textblock/Textbox controls. Use converter to set forecolor of textbox as per the binded value to Text property

      -Abhijeet B

      1 Reply Last reply
      0
      • P picasso2

        Hello members, I have tables (DBTable) in SQL 2008 that contains two columns that look like this: Col1 Col2 0 1 0 1 1 1 1 1 0 1 I created a Silverlight application (BI -RIA and domain services) that populates the datagrid as follows MyCarsDomainContext context = new MyCarsDomainContext(); dataGrid1.ItemsSource = context.DBTables; context.Load(context.GetDBTablesCompareQuery()); I would like to change the row background color (just the text color will work fine too) based on the value of Col1. If 0 then row is red, if 1 then row is blue Any help is greatly appreciated

        A Offline
        A Offline
        Abhinav S
        wrote on last edited by
        #3

        You can do this via the converter approach. Call the converter during binding and set data fore color to the respective color in the converter. A simple example here[^].

        Apps - Color Analyzer | Arctic | XKCD | Sound Meter | Speed Dial

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups