색상을 적용하는 방식 두가지.

예제 코드

            // 사각형A 만들기
            Rectangle myBar = new Rectangle();
            myBar.Width = 100;
            myBar.Height = 100;
            // 컬러 브러시 만드는 부분
            SolidColorBrush myBrush = new SolidColorBrush();
            myBrush.Color = Color.FromArgb(0xff, 0xff, 0, 0);
            // 만든 브러시로 사각형에 칠하기
            myBar.Fill = myBrush;

            // 화면에 보여주기
            LayoutRoot.Children.Add(myBar);
           

            // 사각형B 만들기
            Rectangle myBar2 = new Rectangle();
            myBar2.Width = 100;
            myBar2.Height = 100;
            myBar2.SetValue(Canvas.LeftProperty, (double)100);
            // 컬러 브러시 만드는 부분
            SolidColorBrush myBrush2 = new SolidColorBrush();
            myBrush2.Color = Colors.Blue;
            // 만든 브러시로 사각형에 칠하기
            myBar2.Fill = myBrush2;

            // 화면에 보여주기
            LayoutRoot.Children.Add(myBar2);

Posted by 데모집팀 황리건