XAML - Binding to DataContext and using converter?

后端 未结 2 1481
一生所求
一生所求 2021-02-12 23:54

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


How do you do this using a converter in the mix?

相关标签:
2条回答
  • 2021-02-13 00:20

    Dot sign also provide DataContext Binding for SL developers

    <TextBlock Text="{Binding Path=.,Converter={StaticResource converter}}" />
    
    0 讨论(0)
  • 2021-02-13 00:35

    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>
    
    0 讨论(0)
提交回复
热议问题