none
Failed to create a 'System.Windows.DependencyProperty' from the text 'Template'

    Question

  • Hello Everyone,

    I get this super wired Exception, that makes no sense at all to me. I changed the Base class of this Control to ": Control" and changed some content since then I get all this strange Exception. I would appreciate any kind of Help extremely, I am stuck. Kind Blessings Andreas

    C# class:

    publicclassCustomDataGridAdvanced : Control {.....}

      

    Style:

    <Style TargetType="customcontrols:CustomDataGridAdvanced"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="customcontrols:CustomDataGridAdvanced">

     ....Some Content               

    </ControlTemplate></Setter.Value></Setter></Style>

    _______________________________________________

    {System.Windows.Markup.XamlParseException: Failed to create a 'System.Windows.DependencyProperty' from the text 'Template'. [Line: 5 gt; System.TypeInitializationException: The type initializer for 'Zoa.Silverlight.Application.Helpers.Controls.CustomDataGridAdvanced' threw an exception. ---> System.ArgumentException: Default value type does not match type of property.
       at System.Windows.DependencyProperty.Register(Boolean fIsAttachedDP, String name, Type propertyType, Type ownerType, PropertyMetadata propertyMetadata, Boolean readOnly)
       at System.Windows.DependencyProperty.Register(String name, Type propertyType, Type ownerType, PropertyMetadata typeMetadata)
       at Zoa.Silverlight.Application.Helpers.Controls.CustomDataGridAdvanced..cctor()
       --- End of inner exception stack trace ---
       at System.Runtime.CompilerServices.RuntimeHelpers._RunClassConstructor(RuntimeType type)
       at System.Windows.DependencyProperty.QueryRegisteredProperty(String name, Type ownerType)
       at MS.Internal.ManagedTypeInfoProviderRPInvokes.LookupDependencyProperty(Type type, String name)
       at MS.Internal.ManagedTypeInfoProviderRPInvokes.ResolveDependencyPropertyName(XamlTypeToken sTypeToken, String inPropertyName, XamlPropertyToken& outProperty, XamlTypeToken& outPropertyTypeToken)
       --- End of inner exception stack trace ---
       at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
       at Zoa.Silverlight.Application.App.InitializeComponent()
       at Zoa.Silverlight.Application.App..ctor()}


    Andreas Bolliger

    Friday, March 1, 2013 7:10 AM

Answers

  • Thanks so much for your answer, I found the problem. It was a Dependency Property, where the default initial Value Type and its bas type were not matching it had nothing to do with the Template property, which trough me off. Kind blessings Andreas

    Andreas Bolliger

    • Marked as answer by BolligeA Thursday, March 7, 2013 3:25 PM
    Thursday, March 7, 2013 3:25 PM

All replies

  • Hi,

    I see that you have create a control class. From the error" Failed to create a 'System.Windows.DependencyProperty' from the text 'Template'", it seems something wrong with the custom control. Please try to check if the custom control has the Property named Template.

    Best Regards.


    Amy Peng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Tuesday, March 5, 2013 2:36 AM
    Moderator
  • Thanks so much for your answer, I found the problem. It was a Dependency Property, where the default initial Value Type and its bas type were not matching it had nothing to do with the Template property, which trough me off. Kind blessings Andreas

    Andreas Bolliger

    • Marked as answer by BolligeA Thursday, March 7, 2013 3:25 PM
    Thursday, March 7, 2013 3:25 PM