SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

"TypeConverter cannot convert from System.String" exception on WPF designer view

Last post 10-27-2007 2:45 PM by DanielGrunwald. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 10-27-2007 2:03 PM

    • itaibh
    • Top 25 Contributor
    • Joined on 10-01-2006
    • Israel
    • Posts 99

    "TypeConverter cannot convert from System.String" exception on WPF designer view

    This expection occures when trying to develop a WPF UserControl that contains resources (perhaps it happens not just with UserControls...)

    The full exception:

    System.NotSupportedException: TypeConverter cannot convert from System.String.
       at System.ComponentModel.TypeConverter.GetConvertFromException(Object value)
       at System.ComponentModel.TypeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
       at System.ComponentModel.TypeConverter.ConvertFromString(ITypeDescriptorContext context, CultureInfo culture, String text)
       at ICSharpCode.WpfDesign.XamlDom.XamlTextValue.GetValueFor(XamlPropertyInfo targetProperty)
       at ICSharpCode.WpfDesign.XamlDom.XamlParser.ParseObjectAttribute(XamlObject obj, XmlAttribute attribute)
       at ICSharpCode.WpfDesign.XamlDom.XamlParser.ParseObject(XmlElement element)
       at ICSharpCode.WpfDesign.XamlDom.XamlParser.ParseValue(XmlNode childNode)
       at ICSharpCode.WpfDesign.XamlDom.XamlParser.ParseObjectChildElementAsPropertyElement(XamlObject obj, XmlElement element, XamlPropertyInfo defaultProperty, Object defaultPropertyValue)
       at ICSharpCode.WpfDesign.XamlDom.XamlParser.ParseObject(XmlElement element)
       at ICSharpCode.WpfDesign.XamlDom.XamlParser.Parse(XmlDocument document, XamlParserSettings settings)
       at ICSharpCode.WpfDesign.XamlDom.XamlParser.Parse(XmlReader reader, XamlParserSettings settings)
       at ICSharpCode.WpfDesign.Designer.Xaml.XamlDesignContext..ctor(XmlReader xamlReader, XamlLoadSettings loadSettings)
       at ICSharpCode.WpfDesign.Designer.DesignSurface.LoadDesigner(XmlReader xamlReader, XamlLoadSettings loadSettings)
       at ICSharpCode.WpfDesign.AddIn.WpfViewContent.LoadInternal(OpenedFile file, Stream stream)
       at ICSharpCode.SharpDevelop.Gui.AbstractViewContentHandlingLoadErrors.Load(OpenedFile file, Stream stream)

     

    How to reproduce:

    Write a user control, have it contain a <UserControl.Resources> tag with some styles and templates. Open in it design view.

    Note that this does not affect the correctness of the code/xaml, which compiles and runs flawlessly.

     

    Itai. 

    Filed under: ,
  • 10-27-2007 2:45 PM In reply to

    Re: "TypeConverter cannot convert from System.String" exception on WPF designer view

    Resources, Data Binding, Styles and Templates are not supported by the designer and are completely untested. As I currently don't have time to work on the WPF designer; and you seem to be the only one who currently uses (tries to use) the designer, could you try to fix this problem?

    I suppose the problem here is that bindings in their short form (Property="{StaticResource ...}") are not evaluated, but the parser tries to set the property directly to the string. The XAML parser needs to parse the binding expression and use the StaticResourceExtension to get the real value (actually, System.Windows.StaticResourceExtension only works when parsing BAML, so for the designer, we need our own implementation of the StaticResourceExtension).

    Daniel Grunwald
Page 1 of 1 (2 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.