문제

나는 당신이 이런 식으로 CodeBehind에서 그것을 할 수 있다는 것을 알고 있습니다 ...

#pragma warning disable 67
...
#pragma warning restore 67

그러나 XAML에서 이러한 유형의 일을 할 수있는 방법이 있습니까?

예를 들어, 내 app.xaml에 다음과 같습니다.

<FontFamily x:Key="ExtendedFontFamily">Verdana</FontFamily>

그리고 그것은 계속 해서이 대 오류를 던지고 있습니다 (성공적으로 구축 되더라도) ...

오류 1 유형 'fontfamily'는 공개되지 않거나 공개 매개 변수가없는 생성자 또는 유형 변환기를 정의하지 않기 때문에 객체 요소로 사용할 수 없습니다. C : users jed.hunsaker Documents Work work nextgen src eso.app.reporting eso.app.Reporting.ui.SilverLight App.Xaml 8 4 Eso.App.Reporting.ui.silverlight

그리고...

오류 2 'FontFamily'유형은 직접 컨텐츠를 지원하지 않습니다. C : users jed.hunsaker Documents Work work nextgen src eso.app.reporting eso.app.Reporting.ui.SilverLight App.Xaml 8 42 eso.app.Reporting.ui.silverlight

당신이 당신의 app.xaml에 글꼴을 저장하는 더 좋은 방법을 알지 않는 한, 나는 모두 귀입니다!

도움이 되었습니까?

해결책

리소스 사전을 사용해야합니다. 예는 다음과 같습니다.

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

    <FontFamily x:Key="ExtendedFontFamily">Verdana</FontFamily>
</ResourceDictionary>

그리고 당신은 당신에게 app.xaml과 같이 (리소스 폴더에 있다고 가정)를 참조해야합니다.

<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                x:Class="SilverlightApplication3.App"
                >
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Resources/Fonts.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top