728x90
반응형
728x170
▶ MainWindow.cs
using System;
using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
namespace TestProject
{
/// <summary>
/// 메인 윈도우
/// </summary>
public class MainWindow : Window
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainWindow()
/// <summary>
/// 생성자
/// </summary>
public MainWindow()
{
Title = "ToggleButton 클래스 사용하기";
Width = 800;
Height = 600;
FontFamily = new FontFamily("나눔고딕코딩");
FontSize = 16;
ToggleButton button = new ToggleButton();
button.HorizontalAlignment = HorizontalAlignment.Center;
button.VerticalAlignment = VerticalAlignment.Center;
button.Padding = new Thickness(5);
button.IsChecked = (ResizeMode == ResizeMode.CanResize);
button.Content = "Can _Resize";
button.Checked += button_Checked;
button.Unchecked += button_Checked;
Content = button;
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Static
//////////////////////////////////////////////////////////////////////////////// Public
#region 프로그램 시작하기 - Main()
/// <summary>
/// 프로그램 시작하기
/// </summary>
[STAThread]
public static void Main()
{
Application application = new Application();
application.Run(new MainWindow());
}
#endregion
////////////////////////////////////////////////////////////////////////////////////////// Instance
//////////////////////////////////////////////////////////////////////////////// Private
#region 버튼 체크시 처리하기 - button_Checked(sender, e)
/// <summary>
/// 버튼 체크시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void button_Checked(object sender, RoutedEventArgs e)
{
ToggleButton button = sender as ToggleButton;
ResizeMode = (bool)button.IsChecked ? ResizeMode.CanResize : ResizeMode.NoResize;
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] Button 클래스 : 버튼 장식하기 (0) | 2018.03.18 |
---|---|
[C#/WPF] 색상 선택하기 (0) | 2018.03.18 |
[C#/WPF] 날짜 계산하기 (0) | 2018.03.18 |
[C#/WPF] 디렉토리 탐색하기 (0) | 2018.03.18 |
[C#/WPF] RichTextBox 클래스 사용하기 (0) | 2018.03.18 |
[C#/WPF] CommandBinding 클래스 사용하기 (0) | 2018.03.10 |
[C#/WPF] FrameworkElement 클래스 : 커스텀 엘리먼트 사용하기 (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 |
댓글을 달아 주세요