Window 스타일 및 템플릿

이 항목에서는 Window 컨트롤의 스타일 및 템플릿을 설명합니다. 기본값을 수정할 수 있습니다 ControlTemplate 고유한 모양을 제어할 수 있습니다. 자세한 내용은 컨트롤의 템플릿 만들기를 참조하세요.

창 부분

Window 컨트롤에는 명명된 부분이 없습니다.

창 상태

다음 표에서는 Window 컨트롤의 시각적 개체 상태를 나열합니다.

VisualState 이름 VisualStateGroup 이름 설명
Valid ValidationStates 컨트롤에서 Validation 클래스를 사용하고 Validation.HasError 연결된 속성은 false입니다.
InvalidFocused ValidationStates Validation.HasError 연결된 속성은 true이며 컨트롤에 포커스가 있습니다.
InvalidUnfocused ValidationStates Validation.HasError 연결된 속성은 true이며 컨트롤에 포커스가 없습니다.

Window ControlTemplate

다음 예제는 컨트롤에 대한 기본 템플릿의 약간 수정된 복사본입니다.Window

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Style x:Key="WindowStyle1" TargetType="{x:Type Window}">
        <Setter Property="Foreground"
                Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
        <Setter Property="Background"
                Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Window}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <AdornerDecorator>
                            <ContentPresenter/>
                        </AdornerDecorator>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="Window.ResizeMode"
                     Value="CanResizeWithGrip">
                <Setter Property="Template"
                        Value="{StaticResource WindowTemplateKey}"/>
            </Trigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>

참고 항목