{0} is not valid for Setter.Value. The only supported MarkupExtension types are DynamicResourceExtension and BindingBase or derived types
Asked Answered
K

1

9

I've got a XAML issue, in a project where working on vs2010 we use our own CustomBinding when using DynamicResource in my XAML the Designer throws me the following expception :

CustomBinding is not valid for Setter.Value. The only supported MarkupExtension types are DynamicResourceExtension and BindingBase or derived types.

even though it's not in use in that particular extension.

<SomeControl Value="{CustomBinding SomeValue} Style="{DynamicResource SomeStyle}"/>

Style="{DynamicResource SomeStyle}" is the part which throws the design time exception and the style is never set as a result.

If any one came across a similar issue, please advise.

Katy answered 14/10, 2012 at 9:43 Comment(8)
Is your CustomBinding deriving from Binding class?Buttons
it derives from MarkupExtensionKaty
Is it safe to assume that your missing quote (Value="...) isn't missing in your actual source control? If so, what's the definition of CustomBinding? If, as you say, it derives from MarkupExtension then your answer should be obvious: you have to derive from DynamicResourceExtension or BindingBase instead, as the error message suggests.Epimorphosis
true , but the error is given when applying Style="{DynamicResource SomeStyle}" not in any place using CustomBindingKaty
But the error message says something else mate.Buttons
I believe it's complaining about the wrong block of code -- it's actually the code in the SomeStyle definition that's throwing the issue. -- If you open the designer to that specific file, you may get intellisense help. -- You're probably using a property setter somewhere the the value set to something like a MarkupExtension -- which won't work because you're specifying a value for a style definition (and not a target object -- seems silly to me; but don't shoot the messenger -- I didn't design XAML!).Vo
Found a work around to make the compiler error go away: #4624407Vo
Same errors here, tracked it down to an internal class instantiated inside Application.Resources. Making my internal class public fixed designer issues for me.Baynebridge
S
5

Setter.Value used in your Style only support some hardcoded classes (StaticResource, DynamicResource and BindingBase) because providing of a value has to be deferred to the point when Styles are applied and it seems they had not enough time to implement it properly so they check for the supported classes and apply them later.

Shelburne answered 23/9, 2013 at 12:23 Comment(4)
This is so sad!Hinrichs
It has worked for more than one year and now I get this stupid error and my styles and preview is not working anymore! Is there a solution for that? Just returning this is not working!Concessionaire
@DominicJonas i think they changed the implementation between .NET 3.5 and 4.0 so some things behave slightly different. I solved most of my problems however,. Ask a question and i might be able to help.Shelburne
I have read the .Net Framework source code and technically it makes no sense to me, why Setter.Value denies custom MarkupExtensions as a value provider. I really would like to talk to the engineer, who programmed this. Source: referencesource.microsoft.com/#PresentationFramework/src/…Wordless

© 2022 - 2024 — McMap. All rights reserved.