XAML - Binding to DataContext and using converter?

后端 未结 2 1000
抹茶落季
抹茶落季 2021-02-12 23:35

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:10

    Dot sign also provide DataContext Binding for SL developers

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

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