Window 클래스

정의

애플리케이션 창을 나타냅니다.

public ref class Window sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class Window final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class Window
Public NotInheritable Class Window
상속
Object Platform::Object IInspectable Window
특성

Windows 요구 사항

디바이스 패밀리
Windows 10 (10.0.10240.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v1.0에서 도입되었습니다.)

예제

다음 코드 예제에서는 Microsoft Visual Studio의 빈 애플리케이션 템플릿에 대해 생성된 OnLaunched 메서드 재정의를 보여줍니다. 이 코드는 CurrentContent 속성 및 Activate 메서드에 대한 일반적인 사용 패턴을 보여 줍니다.

protected override void OnLaunched(LaunchActivatedEventArgs args)
{
    // Create a Frame to act navigation context and navigate to the first page
    var rootFrame = new Frame();
    rootFrame.Navigate(typeof(BlankPage));

    // Place the frame in the current Window and ensure that it is active
    Window.Current.Content = rootFrame;
    Window.Current.Activate();
}
Protected Overrides Sub OnLaunched(args As 
    Windows.ApplicationModel.Activation.LaunchActivatedEventArgs)

    ' Create a Frame to act navigation context and navigate to the first page
    Dim rootFrame As New Frame()
    rootFrame.Navigate(GetType(BlankPage))

    ' Place the frame in the current Window and ensure that it is active
    Window.Current.Content = rootFrame
    Window.Current.Activate()
End Sub

설명

이 클래스는 현재 Application의 창을 나타냅니다. 정적 Application 속성과 동일한 방식으로 정적 Current 속성은 앱 창 개체를 반환합니다. 이 개체에서 앱은 Dispatcher 를 활용하거나 Bounds 속성에서 Window의 크기를 확인할 수 있습니다. Window의 가장 일반적인 사용법은 앱 UI를 나타내는 콘텐츠UIElement를 설정하는 것입니다. 이 작업은 일반적으로 앱 활성화의 일부로 수행됩니다(예: OnLaunched 재정의). 창의 수명 동안 이 창 콘텐츠를 변경할 수 있습니다.

Window 클래스는 컨트롤이 아니므로 XAML 표현이 없습니다.

Window 개체는 CoreWindow의 정보를 표시하기만 하면 되며, 이 정보는 시스템에서 만든 창을 참조합니다.

초기 활성화에 사용하는 모든 창에서 활성화 를 호출해야 합니다. Microsoft Visual Studio의 기본 앱 템플릿을 사용하는 경우 Window.Activate 를 호출하는 것은 app.xaml 코드 숨김 파일의 초기 코드에 속합니다.

Microsoft Visual Studio의 일부 애플리케이션 템플릿에 포함된 LayoutAwarePage 클래스는 ApplicationViewState 값과 일치하는 시각적 상태를 추적하는 데 사용되는 SizeChanged 이벤트에 대한 처리를 제공합니다. LayoutAwarePage에는 경계 를 확인하고 이 값을 사용하여 페이지 전체 입력 이벤트가 처리되는 방식에 영향을 주는 코드도 있습니다.

버전 기록

Windows 버전 SDK 버전 추가된 값
1703 15063 Compositor
1903 18362 UIContext

추가 인터페이스 멤버

IXamlSourceTransparency.IsBackgroundTransparent현재 스레드에 있는 모든 DesktopWindowXamlSource 개체의 배경이 투명한지 여부를 지정하는 값을 가져오거나 설정합니다.

속성

Bounds

창의 클라이언트 영역의 원점, 높이 및 너비를 디바이스 독립적 픽셀(DIP)으로 포함하는 Rect 값을 가져옵니다.

Compositor

이 창의 Compositor 를 가져옵니다.

Content

애플리케이션 창의 시각적 루트를 가져오거나 설정합니다.

CoreWindow

애플리케이션 창에 대한 내부 코어 개체를 가져옵니다.

Current

현재 스레드의 창을 가져옵니다.

Dispatcher

일반적으로 UI 스레드의 CoreDispatcherWindowCoreDispatcher 개체를 가져옵니다.

UIContext

창의 컨텍스트 식별자를 가져옵니다.

Visible

창이 표시되는지 여부를 보고하는 값을 가져옵니다.

메서드

Activate()

애플리케이션 창을 포그라운드로 가져오고 입력 포커스를 설정하여 애플리케이션 창을 활성화하려고 시도합니다.

Close()

애플리케이션 창을 닫습니다.

SetTitleBar(UIElement)

XAML 요소가 제목 표시줄인 것처럼 시스템과 상호 작용하게 합니다.

이벤트

Activated

창이 성공적으로 활성화되었을 때 발생합니다.

Closed

창이 닫혔을 때 발생합니다.

SizeChanged

앱 창이 처음 렌더링되었거나 렌더링 크기를 변경했을 때 발생합니다.

VisibilityChanged

Visible 속성의 값이 변경되면 발생합니다.

적용 대상

추가 정보