Silverlight - Canvas 用C#填Background顏色
大家通常在玩Silverlight
通常都會使用Blend..
然後拉一拉就把XAML就做好..
非常溫馨的IDE..
但是常常有需求就是我必須要動態的生出Canvas..
這時候就發現怎麼跟想像的作法有點不太一樣..
在XAML下面..
<canvas background="DimGray" canvas.left="314" canvas.top="152" height="100" name="canvas1" width="200" />
如果再C# 裡面..
要加入背景顏色的方法會是..
Canvas sampleCanvas= new Canvas();
SolidColorBrush brush = new SolidColorBrush();
brush.Color = Color.FromArgb(200, 100, 100, 100);
sampleCanvas.Background = brush;
重點在於 Color.FromArgb(200, 100, 100, 100);
她的四個值..
就是ARGB拉~~~
因為很常忘記這作法..
memo一下...
標籤:
Silverlight
|
This entry was posted on 晚上7:29
and is filed under
Silverlight
.
You can follow any responses to this entry through
the RSS 2.0 feed.
You can leave a response,
or trackback from your own site.
0 意見:
張貼留言