Reputation: 13343
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.
Upvotes: 17
Views: 8903
Reputation: 5716
Dot sign also provide DataContext Binding for SL developers
<TextBlock Text="{Binding Path=.,Converter={StaticResource converter}}" />
Upvotes: 1
Reputation: 204139
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>
Upvotes: 34