728x90
반응형
728x170
■ LinearGradientBrush 클래스의 GradientStops 속성을 사용하는 방법을 보여준다.
▶ MainPage.xaml
<Page x:Class="TestProject.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
FontFamily="나눔고딕코딩"
FontSize="16">
<Grid Name="rootGrid"
Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<TextBlock Name="textBlock"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="96"
FontWeight="Bold"
Text="Windows 10" />
</Grid>
</Page>
▶ MainPage.xaml.cs
using Windows.Foundation;
using Windows.UI;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
namespace TestProject
{
/// <summary>
/// 메인 페이지
/// </summary>
public sealed partial class MainPage : Page
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainPage()
/// <summary>
/// 생성자
/// </summary>
public MainPage()
{
InitializeComponent();
#region 전경 브러시를 설정한다.
LinearGradientBrush foregroundBrush = new LinearGradientBrush();
foregroundBrush.StartPoint = new Point(0, 0);
foregroundBrush.EndPoint = new Point(1, 0);
GradientStop gradientStop1 = new GradientStop();
gradientStop1.Offset = 0;
gradientStop1.Color = Colors.Blue;
foregroundBrush.GradientStops.Add(gradientStop1);
GradientStop gradientStop2 = new GradientStop();
gradientStop2.Offset = 1;
gradientStop2.Color = Colors.Red;
foregroundBrush.GradientStops.Add(gradientStop2);
#endregion
#region 배경 브러시를 설정한다.
LinearGradientBrush backgroundBrush = new LinearGradientBrush
{
StartPoint = new Point(0, 0),
EndPoint = new Point(1, 0)
};
backgroundBrush.GradientStops.Add(new GradientStop
{
Offset = 0,
Color = Colors.Red
});
backgroundBrush.GradientStops.Add(new GradientStop
{
Offset = 1,
Color = Colors.Blue
});
#endregion
this.textBlock.Foreground = foregroundBrush;
this.rootGrid.Background = backgroundBrush;
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'C# > UWP' 카테고리의 다른 글
[C#/UWP] Polyline 클래스 : 아르키메데스 나선(Archimedes Spiral) 그리기 (0) | 2019.01.28 |
---|---|
[C#/UWP] ResourceDictionary 엘리먼트 : MergedDictionaries 사용해 리소스 파일 병합하기 (0) | 2019.01.28 |
[C#/UWP] x:Key 속성을 사용해 리소스 사용하기 (0) | 2019.01.27 |
[C#/UWP] TextBlock 클래스 사용하기 (0) | 2019.01.27 |
[C#/UWP] LinearGradientBrush 클래스 사용하기 (0) | 2019.01.27 |
[C#/UWP] 최소 실행 코드 사용하기 (0) | 2019.01.27 |
[C#/UWP] BitmapImage 클래스 : UriSource 속성을 사용해 리소스 이미지 표시하기 (0) | 2019.01.27 |
[C#/UWP] x:Name 속성 사용하기 (0) | 2019.01.27 |
[C#/UWP] MediaElement 클래스 사용하기 (0) | 2019.01.27 |
[C#/UWP] Grid 클래스 : 자식 엘리먼트 중첩시키기 (0) | 2019.01.27 |
댓글을 달아 주세요