2009-07-27 5 views
7

...XAMLによってスローされたVisual Studioのエラーを無視する方法はありますか?私はあなたがこのような何かを分離コードでそれを行うことができます知っている

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

しかし、XAMLで事のこのタイプを行う方法はありますか?

例えば、(それが正常にビルドも)私は...私のApp.xamlに

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

を次のようにして、それがエラーVS私にこれらを投げ続ける...

エラー1型 'FontFamily'は がオブジェクト要素として使用できません。 はパブリックではないか、 パブリックパラメータなしコンストラクタまたは タイプ コンバータを定義していないためです。 C:¥Users¥jed.hunsaker¥Documents¥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¥NextGen¥src¥ESO.App.Reporting¥ESO.App.Reporting.UI.Silverlight¥App.xaml 8 42 ESO.App.Reporting.UI.Silverlight

あなたのApp.xamlにFontFamilyを保存する方法が分かっていない限り、私はすべて耳にします!

答えて

2

リソース辞書を使用する必要があります。次に例を示します。

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

そして、あなたはあなたの中に参照する必要がありますので(彼らはResourcesフォルダにあると仮定した場合)のように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> 
関連する問題