Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The TypeConverter for "FontWeight" does not support converting from a string

After installing Visual Studio 2012 and opening a Silverlight 5 project I'm getting various design time errors related to TypeConverter, such as:

The TypeConverter for "FontWeight" does not support converting from a string.

The TypeConverter for "Point" does not support converting from a string.

The TypeConverter for "Thickness" does not support converting from a string.

That's not an exhaustive list, however.

Examples of these being:

<Setter Property="FontWeight" Value="Bold" />

<RadialGradientBrush GradientOrigin="0.5,0.5"> ...

<Setter Property="Padding" Value="0" />

Am I missing something obvious here, or is this a bug?

like image 411
Wayne Cornish Avatar asked Aug 17 '12 11:08

Wayne Cornish


3 Answers

I had the same problem: defined in the resources section

<UserControl.Resources>
  <local:MyConverter x:Key="myConverter"/>
</UserControl.Resources>

In the XAML UE, I had to change

...Width="{Binding BindingProperty, Converter=myConverter}"...

to

...Width="{Binding BindingProperty, Converter={StaticResource myConverter}..."
like image 154
Dani Avatar answered Sep 22 '22 04:09

Dani


Got a simular problem:

The TypeConverter for "Thickness" does not support converting from a string

No Converters used in this XAML file

It's a silverlight project (Prism) who has been converted from SL4 to SL5. But there seems to be more going on, I also get errors like this:

The specified value cannot be assigned to the collection. The following type was expected: "Inline".

When TextBlock is used like this:

<TextBlock>Hello</TextBlock>

To get rid of that error:

<TextBlock Text="Hello" />

Its a bit cumbersome to start the application to see the result of XAML changes

like image 25
Mojito71 Avatar answered Sep 22 '22 04:09

Mojito71


I had the same problem and it was driving me mad! For me it had to do with the Silverlight Toolkit, once I added that I started getting tons of these errors.

In my project file (right-click->Edit project file) I had referenced the toolkit dll like this (relative to source dir in my case):

<Reference Include="System.Windows.Controls.Toolkit">
    <HintPath>..\..\..\Bin\System.Windows.Controls.Toolkit.dll</HintPath>
</Reference>

Changing it to this seemed to sort it (I'm not sure if internals is needed too but a new project with SL5 and toolkit added seemed to ref it):

<Reference Include="system.windows.controls.toolkit, Version=5.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System.Windows.Controls.Toolkit.Internals, Version=4.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />

Hope that helps, John

like image 37
John Leonard Avatar answered Sep 23 '22 04:09

John Leonard