So I'm making an application where the user can use the sliders to change the background colour. Here is what I have tried:
private void Slider_ValueChanged_1(object sender, RoutedPropertyChangedEventArgs<double> e)
{
Window1.Background = new SolidColorBrush(Color.FromArgb(0, Slider1.Value, Slider2.Value, Slider3.Value));
}
But instead what happens is this:
Error CS1503 Argument 2: cannot convert from 'double' to 'byte'
Error CS1503 Argument 3: cannot convert from 'double' to 'byte'
Error CS1503 Argument 4: cannot convert from 'double' to 'byte'
I tried converting them to byte:
Window1.Background = new SolidColorBrush(Color.FromArgb(0, Convert.ToByte(Slider1.Value), Convert.ToByte(Slider2.Value), Convert.ToByte(Slider3.Value)));
But instead it breaks
NullReferenceException: Object reference not set to an instance of an object.