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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      40 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      20 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      27 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      44 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      37 views
      0 likes
      Last Post CarlTrading  
      Working...
      X