728x90
반응형
728x170
▶ CustomEllipse.cs
using System.Windows;
using System.Windows.Media;
namespace TestProject
{
/// <summary>
/// 커스텀 타원
/// </summary>
public class CustomEllipse : FrameworkElement
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Protected
#region 렌더링시 처리하기 - OnRender(drawingContext)
/// <summary>
/// 렌더링시 처리하기
/// </summary>
/// <param name="drawingContext">그리기 컨텍스트</param>
protected override void OnRender(DrawingContext drawingContext)
{
drawingContext.DrawEllipse
(
Brushes.Blue ,
new Pen(Brushes.Red, 24) ,
new Point(RenderSize.Width / 2, RenderSize.Height / 2),
RenderSize.Width / 2 ,
RenderSize.Height / 2
);
}
#endregion
}
}
728x90
▶ MainWindow.xaml
<Window x:Class="TestProject.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TestProject"
Width="800"
Height="600"
Title="FrameworkElement 클래스 : 커스텀 엘리먼트 사용하기"
FontFamily="나눔고딕코딩"
FontSize="16">
<Grid>
<local:CustomEllipse
Margin="20" />
</Grid>
</Window>
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] 날짜 계산하기 (0) | 2018.03.18 |
---|---|
[C#/WPF] 디렉토리 탐색하기 (0) | 2018.03.18 |
[C#/WPF] RichTextBox 클래스 사용하기 (0) | 2018.03.18 |
[C#/WPF] ToggleButton 클래스 사용하기 (0) | 2018.03.10 |
[C#/WPF] CommandBinding 클래스 사용하기 (0) | 2018.03.10 |
[C#/WPF] RadialGradientBrush 클래스 사용하기 (0) | 2018.03.10 |
[C#/WPF] LinearGradientBrush 클래스 : MappingMode 속성 사용하기 (0) | 2018.03.10 |
[C#/WPF] Type 클래스 : GetProperties 메소드 사용하기 (0) | 2018.03.10 |
[C#/WPF] Window 클래스 : Background 속성을 사용해 배경색 변경하기 (0) | 2018.03.10 |
[C#/WPF] Application, Window 클래스 상속하기 (0) | 2018.03.10 |
댓글을 달아 주세요