WPF Nested Markup Extension Bug - by indefinite_lurker

Status : 


Sign in
to vote
ID 509234 Comments
Status Active Workarounds
Type Bug Repros 15
Opened 11/9/2009 2:21:17 AM
Access Restriction Public


I recently was implementing a custom Markup Extension, however I stumbled across a problem, and was faced with an error message in Visual Studio.

The problem is also faced before in VS2008, and is still not fixed in VS2010 BETA 2, this blog post highlights the issue:


Sign in to post a comment.
Posted by Microsoft on 7/25/2012 at 9:58 PM
The WPF team has recently reviewed this issue and will not be addressing this issue as at this time the team is focusing on the bugs impacting the highest number of WPF developers. If you believe that this was resolved in error, please reactivate this bug with any necessary supporting details.
Posted by wiyosaya on 3/1/2012 at 12:26 PM
I also ran into this trying to bind to ancestors in conditions on a MultiDataTrigger

Here's the xaml:

        <Condition Binding="{Binding RelativeSource={RelativeSource, Mode=FindAncestor,
            AncestorType={x:Type ComboBoxItem}}, Path=IsSelected}" Value="false" />
        <Condition Binding="{Binding RelativeSource={RelativeSource, Mode=FindAncestor,
            AncestorType={x:Type ComboBox}}, Path=IsDropdownOpen}" Value="true" />
    <Setter Property="Visibility" Value="Collapsed" />

The explicit property/value syntax is a work-around - this is not the exact replacement xaml for the above, but it is similar-
                        <RelativeSource Mode="FindAncestor" AncestorType="{x:Type ComboBoxItem}"/>
                        <RelativeSource Mode="FindAncestor" AncestorType="{x:Type ComboBox}"/>
    <Setter Property="Visibility" Value="Visible" />
Posted by Mark Heath on 2/21/2012 at 7:37 AM
I ran into this, trying to use a custom IValueConverter inside a DataTemplate. Following simplified app.xaml:
        <my:CallFillBrushConverter x:Key="callFillBrushConverter" />
        <DataTemplate x:Key="callTemplate">
            <Rectangle Fill="{Binding, Converter={StaticResource callFillBrushConverter}}" />

will produce the following error:

Unknown property 'Converter' for type 'MS.Internal.Markup.MarkupExtensionParser+UnknownMarkupExtension' encountered while parsing a Markup Extension.

Workaround of using the property syntax does work however:
        <DataTemplate x:Key="callTemplate">
                    <Binding Converter="{StaticResource callFillBrushConverter}"/>
Posted by Gazzzzzzer on 9/9/2011 at 9:37 AM
Can you please provide an update to this bug.

Using the workaround will be changing the way we implement our code (consistency issue) in places.

This has been an issue for a number of versions of Visual Studio , developers have been reporting this since 2006!

Please can someone look at this issue an include a fix for future versions, service packs, patches!

A frustrated Developer
Posted by JonSlaughter on 4/18/2011 at 10:19 AM
Wow, I guess this will never get fixed?!?!?!
Posted by Christian Walther on 3/14/2011 at 9:21 AM
For the record, I am having a similar experience in Visual Studio 2010 SP1 that may or may not be a symptom of the same problem.

I have a custom markup extension ("Localize") and pass a {Binding} to it as a constructor argument, e.g.

<TextBlock Text="{loc:Localize {Binding ElementName=testtb, Path=Text}}"/>

As jods observes, this compiles and runs fine, but breaks the designer, where "break the designer" means that the designer occasionally fails to reload with the following exception:

NullReferenceException was thrown due to document error:
Object reference not set to an instance of an object.
at Microsoft.Expression.DesignModel.InstanceBuilders.ExpressionCache.Validate(IInstanceBuilderContext context, List`1& sites)
at Microsoft.Expression.DesignModel.Core.ViewNodeManager.InvalidateInternal(List`1 invalidRoots, Boolean forceValidateExpressionCache)
at Microsoft.Windows.Design.Platform.ViewProducerBase.ApplyUpdate(Delta delta)
at Microsoft.Windows.Design.Platform.ViewProducerBase.IncrementalRebuild(DocumentTreeManager tree, Damage damage)
at Microsoft.Windows.Design.Platform.ViewProducerBase.UpdateView(DocumentTreeManager tree, Damage damage)
at Microsoft.Windows.Design.DocumentModel.ViewProducer.UpdateView(UpdateDamageArguments args)

This specifically happens when I add or remove an object to/from the XAML. Merely changing an attribute value usually works. Closing and reopening the XAML editor window gets it back into a working state.

It is unlikely to be a problem in my own code, as it also happens when the LocalizeExtension completely ignores its constructor argument, while replacing the argument by a literal string fixes it. Using other markup extensions than {Binding}, e.g. {StaticResource} or {x:Null}, also triggers it.

Putting the markup extension in a separate assembly does not help - I see no difference.

Using property element syntax does not work in the {Binding} case because when I try to assign a <Binding> to the property of the LocalizeExtension that corresponds to the constructor argument, it thinks that I want to bind that property, which doesn't work because it is not a dependency property. That is not what I want, I want to pass the actual Binding object to the markup extension.

The problem does not occur when designing in Expression Blend 4, only in Visual Studio.
Posted by jods on 2/25/2010 at 8:28 AM
Using the VS 2010 RC, having an extension (e.g. {x:Type}) as a constructor parameter to a custom MarkupExtension breaks the designer (but compiles and runs).
Posted by Microsoft on 11/10/2009 at 1:30 AM
Thank you for your feedback, We are currently reviewing the issue you have submitted.