728x90
반응형
728x170
■ WindowsFormsHost 엘리먼트에서 Visibility 속성을 설정하여 Windows Forms 컨트롤을 보이지 않게 만들거나 축소할 수 있다. 컨트롤이 보이지 않으면 표시되지 않지만 레이아웃 공간을 차지한다. 컨트롤이 축소되면 표시되지 않으며 레이아웃 공간을 차지하지도 않는다.
▶ 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:winform="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
Width="800"
Height="600"
Title="TestProject"
FontFamily="나눔고딕코딩"
FontSize="16">
<Grid
Margin="10"
ShowGridLines="true">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="1" Grid.Column="1">
<Button Name="invisibleButton"
Background="OrangeRed"
Content="Click to make invisible" />
<WindowsFormsHost Name="host"
Background="Yellow">
<winform:Button
FlatStyle="Flat"
Text="Windows Forms control" />
</WindowsFormsHost>
<Button Name="collapseButton"
Background="OrangeRed"
Content="Click to collapse" />
</StackPanel>
</Grid>
</Window>
▶ MainWindow.xaml.cs
using System;
using System.Windows;
namespace TestProject
{
/// <summary>
/// 메인 윈도우
/// </summary>
public partial class MainWindow : Window
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainWindow()
/// <summary>
/// 생성자
/// </summary>
public MainWindow()
{
InitializeComponent();
this.invisibleButton.Click += invisibleButton_Click;
this.collapseButton.Click += collapseButton_Click;
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
#region Click to make invisible 버튼 클릭시 처리하기 - invisibleButton_Click(sender, e)
/// <summary>
/// Click to make invisible 버튼 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void invisibleButton_Click(object sender, EventArgs e)
{
this.host.Visibility = Visibility.Hidden;
}
#endregion
#region Click to collapse 버튼 클릭시 처리하기 - collapseButton_Click(sender, e)
/// <summary>
/// Click to collapse 버튼 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void collapseButton_Click(object sender, EventArgs e)
{
this.host.Visibility = Visibility.Collapsed;
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] WindowsFormsHost 엘리먼트 : 하이브리드 애플리케이션에서 데이터 바인딩하기 (0) | 2022.12.31 |
---|---|
[C#/WPF] WindowsFormsHost 엘리먼트 : WinForm 레이아웃 컨트롤 사용하기 (0) | 2022.12.29 |
[C#/WPF] WindowsFormsHost 엘리먼트 : Margin/Padding 속성 사용하기 (0) | 2022.12.29 |
[C#/WPF] WindowsFormsHost 엘리먼트 : 회전 설정하기 (0) | 2022.12.29 |
[C#/WPF] WindowsFormsHost 엘리먼트 : 스케일링 설정하기 (0) | 2022.12.29 |
[C#/WPF] WindowsFormsHost 엘리먼트 : 도킹 설정하기 (0) | 2022.12.29 |
[C#/WPF] WindowsFormsHost 엘리먼트 : Z 순서 제한 이해하기 (0) | 2022.12.29 |
[C#/WPF] WindowsFormsHost 엘리먼트 : 호스팅된 컨트롤 레이아웃 속성 설정하기 (0) | 2022.12.29 |
[C#/WPF] WindowsFormsHost 엘리먼트 : Width/Height 속성을 사용해 명시적으로 크기 설정하기 (0) | 2022.12.29 |
[C#/WPF] WindowsFormsHost 엘리먼트 : 절대 위치 지정 사용하기 (0) | 2022.12.29 |
댓글을 달아 주세요