Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cannot convert type 'SharpDX.Direct2D1.Brush' to 'System.Windows.Media.Brush'

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

    Cannot convert type 'SharpDX.Direct2D1.Brush' to 'System.Windows.Media.Brush'

    Hi,
    I am setting a color in onrender method and want to take that color and update the color of my candle. I an trying to use CandleOutlineBrushes on onupdate method.


    I am getting this error ---- Cannot convert type 'SharpDX.Direct2D1.Brush' to 'System.Windows.Media.Brush'

    onupdate
    private Brush currCandleColor;


    onrender
    SharpDX.Direct2D1.Brush customBrush = Brushes.DarkGoldenrod.ToDxBrush(RenderTarget);
    currCandleColor = (Brush)customBrush;
    Thanks in advance

    #2
    Right, because currCandleColor is a System.Windows.Media.Brush.

    You should be doing currCandleColor = Brushes.DarkGoldenrod. Or, change the definition of currCandleColor to be a SharpDX.Direct2D1.Brush instead (I don't really recommend this unless you TRULY know what you are doing, because it is easy to cause problems this way).

    You can't convert from a SharpDX brush back to a system brush like that just by casting it.
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Thanks Bruce.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      44 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      54 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      34 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      95 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      57 views
      0 likes
      Last Post PaulMohn  
      Working...
      X