Frage

Ich weiß, dass Sie es in Codebehind mit etwas tun können, wie diese ...

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

Aber ist es eine Möglichkeit, diese Art der Sache in XAML zu tun?

Zum Beispiel habe ich folgendes in meinem App.xaml ...

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

Und es hält werfen mir diese VS Fehler (auch wenn es erfolgreich erstellt) ...

  

Fehler 1 Type 'Fontfamily' ist nicht   weil es verwendbar als Objektelement   nicht öffentlich ist oder nicht definiert ein   Öffentliche parameterlosen Konstruktor oder ein   Art   Konverter. C: \ Users \ jed.hunsaker \ Dokumente \ Arbeit \ NextGen \ src \ ESO.App.Reporting \ ESO.App.Reporting.UI.Silverlight \ App.xaml 8 4 ESO.App.Reporting.UI.Silverlight

und ...

  

Fehler 2 Der Typ ‚Fontfamily‘ nicht   unterstützt die direkte   Inhalt. C: \ Users \ jed.hunsaker \ Dokumente \ Arbeit \ NextGen \ src \ ESO.App.Reporting \ ESO.App.Reporting.UI.Silverlight \ App.xaml 8 42 ESO.App.Reporting.UI.Silverlight

Es sei denn, euch einen besseren Weg kennt einen Fontfamily in Ihrem App.xaml zu speichern, ich bin ganz Ohr!

War es hilfreich?

Lösung

Sie sollten ein Ressource-Lexikon nutzen. Hier ein Beispiel:

<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>

Und Sie sollten in Ihnen App.xaml wie so (vorausgesetzt, sie sind in einem Ordner Ressourcen) Referenz:

<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>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top