Question

I'm making a small paint program using wpf's inkcanvas and I've been trying to change the background colour in the c# code so the user will be able change it while it's running by adding RGB values. Could anyone give me an example or point me in the right direction?

Was it helpful?

Solution 2

There are a lot of pre-made colors to use, which can be access as such

myInkCanvas.Background = Brushes.GhostWhite;

To adjust to your updated question

int r, g, b; 
//set r,g,b to something
myInkCanvas.Background = new SolidColorBrush(Color.FromArgb(255, (byte)r, (byte)b, (byte)b));

And for fun, if you have a hex string

myInkCanvas.Background = (Brush) new System.Windows.Media.BrushConverter().ConvertFromString("#FFFFFF90");

With separate hex string

myInkCanvas.Background = new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0x90));

OTHER TIPS

theInkCanvas.Background = new SolidColorBrush(Color.FromRgb(r, g, b));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top