views:

995

answers:

1

To bind to the current DataContext in XAML you can use:

<TextBlock Text="{Binding}" />

How do you do this using a converter in the mix? The following works when you have a property on the path:

<TextBlock Text="{Binding MyProperty,Converter={StaticResource converter}}" />

But I dont want to do that; I just want to Bind to the datacontext and not the datacontext.MyProperty if you get what I mean.

+4  A: 

Simply omit the path:

<TextBlock Text="{Binding Converter={StaticResource converter}}" />

Ah wait - I notice your question is tagged with Silverlight. Does this not work in Silverlight? If not, you may need to use the expanded syntax:

<TextBlock>
    <TextBlock.Text>
        <Binding Converter="{StaticResource converter}" />
    </TextBlock.Text>
</TextBlock>
Matt Hamilton
sigh, that easy. I had left the comma in there which broke it. The 1st one did the trick
burnt_hand
Excellent - I never quite know with Silverlight. Sometimes things that seem very fundamental in WPF are completely absent in Siverlight.
Matt Hamilton