I can declare an integer or double value in xaml. However, I cannot add a decimal value. It works fine, but then I get:
System.Windows.Markup.XamlParseException: The type "Decimal" was not found.
Here is the xaml code:
<UserControl.Resources> <system:Int32 x:Key="AnIntValue">1000</system:Int32> <system:Double x:Key="ADoubleValue">1000.0</system:Double> <system:Decimal x:Key="ADecimalValue">1000.0</system:Decimal> </UserControl.Resources>
This is how I declare a system namespace:
xmlns:system="clr-namespace:System;assembly=mscorlib"
Edit: Workaround: As Stephen noted, adding a resource using code-code seems to work fine:
Resources.Add("ADecimalValue", new Decimal(1000.0));
Edit: answer: Doing exactly the same thing in WPF seems to work fine. Therefore, I assume that this is a hidden limitation of Silverlight. Thanks Steven for this discovery.
source share