문제

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?

도움이 되었습니까?

해결책 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));

다른 팁

theInkCanvas.Background = new SolidColorBrush(Color.FromRgb(r, g, b));
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top