Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

WPF DataGrid - Simply change cell background color

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    WPF DataGrid - Simply change cell background color

    Hi All,

    I have been having difficulty interacting with a "wpf" datagrid.
    In the code, I add a DataGrid to the "System.Windows.Controls.Grid"
    I have populated the grid with some market prices and chart info. Thats all works fine and updates as expected in real time, very nice.

    What i am having major issues with is simply setting the background color of a particlar cell. dataGrid1 does in fact exist and I can get a return on the items count for the DataGrid using:dataGrid1.ItemContainerGenerator.Items.Count

    THE ISSUE - But i can not seem to get a "reference" to the rows or columns of dataGrid1 to change the background color; and any attempts to interact with the rows/cells using the functions GetCell and GetVisualChild, ends with the platform bombing out. The try catch in the code fails to catch the exception.

    This is my first endeavour with WPF and the datagrid, I have used windows forms for years and this is totally baffling me. Also i appreciate this is likely unsupported code, but i would really appreciate anyones' comments or advise.

    Caution: Un-commenting the try catch in the OnBarUpdate event is likely to cause the platform to stop responding.

    Attached Indicator: devGrid.zip
    Attached Files
    Last edited by MaxForex; 10-23-2016, 10:10 AM.

    #2
    Hello MaxForex,

    Thank you for your patience.

    I would recommend drawing rectangle and then coloring those rectangles. There is a discussion on this at the following link as well: http://stackoverflow.com/questions/2...d-color-in-wpf

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by trilliantrader, Today, 08:16 AM
    0 responses
    3 views
    0 likes
    Last Post trilliantrader  
    Started by AttiM, 02-14-2024, 05:20 PM
    9 responses
    174 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by funk10101, Today, 08:14 AM
    0 responses
    1 view
    0 likes
    Last Post funk10101  
    Started by adeelshahzad, Today, 03:54 AM
    1 response
    13 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by RookieTrader, Today, 07:41 AM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X