質問

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