Hi everybody
I want implement a custom MarkupExtension class to extend XAML in Avalon. I had implemented a class that inherit from System.Windows.Serialization.MarkupExtension, the code is similar as follows.
using System.Windows.Serialization;
namespace MarkupExtensionNS
{
public class MyMarkupExtension : MarkupExtension
{
public MyMarkupExtension()
{
}
public override object ProvideValue(object targetObject, object
targetProperty)
{
return "OK";
}
}
}
After, I use follows XAML code to reference my markup extension.
<?Mapping XmlNamespace="CodeMapNS" ClrNamespace="MarkupExtensionNS" ?>
<Window x:Class="MarkupExtensionNS.Window1"
xmlns="http://schemas.microsoft.com/winfx/avalon/2005"
xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005"
Text="MarkupExtension"
xmlns:c="CodeMapNS"
>
<Grid>
<TextBlock TextContent="{c:MyMarkupExtension}"/>
</Grid>
</Window>
But I got a compiler error as follows.
MS.Internal.Markup.XamlParseException: The value '{c:MyMarkupExtension}' is
not a valid MarkupExtension expression. Could not resolve
'MyMarkupExtension' in namespace 'CodeMapNS'. 'MyMarkupExtension' must be a
subclass of MarkupExtension. Line 9 Position 14.
Why?
I had try to move MyMarkupExtension to a new assembly and The original assembly that include the XAML file reference to the new assembly that include the declaration of MyMarkupExtension. But the compiler error is exist always.
Who can help me?
-
-
Hmm... I've had this working just fine in Beta1 RC1, but I tried it again now in Beta 1, and I can't get it to work! I wonder if they changed something...
-
Are you implement custom MarkupExtension in Beta1 RC1? Can you send the source code to me? My MarkupExtension can not working right in Bata1 RC1.
Thanks a lot.
----------------------
I'm Chinese. My English is vary poor. So please help me more. Thanks so much.
----------------------
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.