나는 내가 할 수 아니에요 내 StandardStyle.xaml에서 는
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- Defines the colors used in the app-->
<ResourceDictionary Source="Color.xaml"/>
<!-- Styles that define common aspects of the platform look and
feel Required by Visual Studio project and item templates-->
<ResourceDictionary Source="StandardStyles.xaml"/>
<ResourceDictionary>
............
로
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="MyColor1" Color="#7d897d"/>
<SolidColorBrush x:Key="MyColor2" Color="#078ab4"/>
</ResourceDictionary>
그리고 App.xaml과 같은 사용자 정의 Color.xaml이 xaml에 정의 된 Color를 사용하십시오. 나는 UI의 XAML 파일에이 색상을 사용할 수있어하지만 내가 코드
"Cannot find a Resource with the Name/Key MyColor1 [Line: 20 Position: 44]"
을 실행할 때 그것은 나에게 예외를 제공
<Style x:Key="HeadingTextStyle" TargetType="TextBlock">
<Setter Property="FontWeight" Value="SemiLight"/>
<Setter Property="FontSize" Value="20"/>
<Setter Property="Foreground" Value="{StaticResource MyColor1}"/>
</Style>
. 여기
StandardStyle.Xaml 같은
StandardStyle.xaml
에서Color.xaml
리소스 사전 포함되어있다? 그렇다면 StandardStyle에서 색상 리소스를 병합 했습니까? –아니요 'StandardStyle.xaml'이 아니라'App.xaml'에 병합하지 않았습니다. 'StandardStyle.Xaml'은 리소스 사전입니다. –