WPF Buttons questions

I’m messing around with WPF Buttons for the first time.

2 questions.

  1. On mouse down the background color of the button goes transparent. How to control that? Setting a color on MouseDown does not work. (see below)

  2. OnHover, there’s an ugly blue glow around the button, like an outer glow in royal blue. How do you remove that? I tried myButton.FocusVisualStyle = null; but doesn’t do anything. There was also a lighter blue border onClick but I was able to remove that(focus ring)

     	myButton = new Button
     	{
     	    Content = Button_Text,
     	    Background = Brushes.DarkSlateBlue,
     	    Foreground = Brushes.White,
     	    Width = 180,
     	    Height = 24,
     	    Margin = new Thickness(0, 100, 100, 0),  // L,T,R,B
     	    HorizontalAlignment = HorizontalAlignment.Right,
     	    VerticalAlignment = VerticalAlignment.Top,
     	    FontSize = 14,	
     	};
     	
     	myButton.Focusable = false; // removes OnClick focus ring
     	
     	myButton.PreviewMouseDown += (s, e) =>
     	{
     	    myButton.Background = Brushes.Green;  // DOES NOT WORK
    
     	};
     	
     	myButton.PreviewMouseUp += (s, e) =>
     	{
     	    myButton.Background = ButtonisToggled 
     	        ? Brushes.Red 
     	        : Brushes.Blue; // THIS WORKS
     	};
    
1 Like

https://ninjatrader.com/support/forum/forum/ninjatrader-8/add-on-development/105117-blue-mouse-hover-effect