Share via


방법: 시스템 브러시로 영역 그리기

업데이트: 2007년 11월

SystemColors 클래스를 사용하면 ControlBrush, ControlBrushKeyDesktopBrush와 같은 시스템 브러시 및 색에 액세스할 수 있습니다. 시스템 브러시는 지정된 시스템 색으로 영역을 그리는 SolidColorBrush 개체입니다. 시스템 브러시는 항상 대상을 단색으로 채우므로 그라데이션을 생성하는 데 사용할 수 없습니다.

시스템 브러시를 정적 리소스나 동적 리소스로 사용할 수 있습니다. 응용 프로그램이 실행되는 동안 사용자가 시스템 브러시를 변경할 때 자동으로 브러시가 업데이트되게 하려면 동적 리소스를 사용하고, 그렇지 않은 경우에는 정적 리소스를 사용합니다. SystemColors 클래스에는 다음과 같은 엄격한 명명 규칙을 따르는 다양한 정적 속성이 있습니다.

  • *<SystemColor>*Brush

    지정된 시스템 색의 SolidColorBrush에 대한 정적 참조를 가져옵니다.

  • *<SystemColor>*BrushKey

    지정된 시스템 색의 SolidColorBrush에 대한 동적 참조를 가져옵니다.

  • *<SystemColor>*Color

    지정된 시스템 색의 Color 구조체에 대한 정적 참조를 가져옵니다.

  • *<SystemColor>*ColorKey

    지정된 시스템 색의 Color 구조체에 대한 동적 참조를 가져옵니다.

시스템 색은 브러시를 구성하는 데 사용할 수 있는 Color 구조체입니다. 예를 들어 시스템 색에 LinearGradientBrush 개체의 그라디언트 중지점에 대한 Color 속성을 설정하면 시스템 색을 사용하는 그라데이션을 만들 수 있습니다. 예제를 보려면 방법: 그라데이션에 시스템 색 사용을 참조하십시오.

예제

다음 예제에서는 동적 시스템 브러시 참조를 사용하여 단추의 배경을 설정합니다.

<Page xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
  WindowTitle="SystemColors Example" Background="White">  
  <StackPanel Margin="20">

    <!-- Uses a dynamic resource to set the 
         background of a button. 
         If the desktop brush changes while this application
         is running, this button will be updated. -->
    <Button 
      Background="{DynamicResource {x:Static SystemColors.DesktopBrushKey}}" 
      Content="Hello, World!" />

  </StackPanel>
</Page>

다음 예제에서는 정적 시스템 브러시 참조를 사용하여 단추의 배경을 설정합니다.

<Page xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
  WindowTitle="SystemColors Example" Background="White">  
  <StackPanel Margin="20">

    <!-- Uses a static brush to set the
         background of a button. 
         If the desktop brush changes while this application
         is running, this button will not be updated until
         the page is loaded again. -->
    <Button 
      Background="{x:Static SystemColors.DesktopBrush}" 
      Content="Hello, World!"  /> 

  </StackPanel>
</Page>

그라데이션에서 시스템 색을 사용하는 방법을 보여 주는 예제를 보려면 방법: 그라데이션에 시스템 색 사용을 참조하십시오.

참고 항목

작업

시스템 브러시 및 색 샘플

방법: 그라데이션에 시스템 색 사용

개념

단색 및 그라데이션을 사용한 그리기 개요