I know you can do it in CodeBehind with something like this...
#pragma warning disable 67
...
#pragma warning restore 67
But is there a way to do this type of thing in XAML?
For example, I have the following in my App.xaml...
<FontFamily x:Key="ExtendedFontFamily">Verdana</FontFamily>
And it keeps throwing me these VS errors (even though it builds successfully)...
Error 1 Type 'FontFamily' is not usable as an object element because it is not public or does not define a public parameterless constructor or a type converter. 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
and...
Error 2 The type 'FontFamily' does not support direct content. 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
Unless you guys know a better way to store a FontFamily in your App.xaml, I'm all ears!
You should use a resource dictionary. Here is an example:
<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>
And you should reference in you App.xaml like so (assuming they are in a Resources folder):
<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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With