반응형
XAML에서 변수를 정의하고 사용하여 색상을 정의하려면 어떻게 해야 합니까?
XAML에는 읽기 전용 텍스트 상자의 빛바랜 텍스트 색상으로 Foreground="#555"를 정의하는 요소가 다수 있습니다.
<TextBlock Text="{Binding SingularModelClassFileTitle}" Margin="0 10 0 0"/>
<TextBox Text="{Binding SingularModelClassFileName}"
HorizontalAlignment="Left"
IsReadOnly="True"
Foreground="#555"
Width="500"/>
<TextBox
VerticalScrollBarVisibility="Visible"
AcceptsReturn="True"
Width="500"
Height="100"
IsReadOnly="True"
Foreground="#555"
Text="{Binding SingularModelClassContent}"
HorizontalAlignment="Left"
Margin="0 0 0 20"/>
어떻게 하면 이 값을 XAML 변수에 넣고 각 Atribute에서 참조할 수 있으므로 한 곳에서만 변경할 수 있습니까?
난 네가 이런 걸 할 수 있다고 생각해.
<sys:String x:Key="ReadOnlyTextColor">#555</sys:String>
...
<TextBox Foreground="{StaticResource ReadOnlyTextColor}"/>
그리고 그 성질은 무엇일까?xmlns:sys=...참조할 수 있습니까?
색상을 SolidColorBrush로 정의해 보십시오.
<SolidColorBrush x:Key="ReadOnlyTextBrush" Color="#555555" />
...
<TextBox Foreground="{StaticResource ReadOnlyTextColor}" />
브러시가 아닌 색상을 정의해야 하는 경우가 있습니다(컬러 파라미터로 그라데이션(Gradment)을 정의할 수 있는 경우가 있습니다).이 경우 다음과 같이 정의할 수 있습니다.
<Color x:Key="ButtonColor1">Blue</Color>
<Color x:Key="ButtonColor1">#AABBCC</Color>
<Color x:Key="ButtonColor1" A="0" R="124" G="111" B="44"/>
언급URL : https://stackoverflow.com/questions/1037477/how-can-i-define-and-use-a-variable-in-xaml-to-define-a-color
반응형
'programing' 카테고리의 다른 글
| Mac OS X 10.6에서 하드웨어 비프음을 내는 방법 (0) | 2023.04.12 |
|---|---|
| SQL Server Profiler : "NOT LIKE" 열 필터에 여러 값을 지정하는 방법 (0) | 2023.04.12 |
| 사전에서 키-값 쌍의 하위 집합을 추출하시겠습니까? (0) | 2023.04.12 |
| Bash에서 도트로 구분된 버전 포맷의 두 문자열을 비교하는 방법은 무엇입니까? (0) | 2023.04.12 |
| WPF 어플리케이션에서 콘솔로 출력되지 않았습니까? (0) | 2023.04.12 |