Dan*_*ann 17 silverlight xaml binding
要绑定到XAML中的当前DataContext,您可以使用:
<TextBlock Text="{Binding}" />
Run Code Online (Sandbox Code Playgroud)
你如何在混音中使用转换器?当您在路径上拥有属性时,以下内容有效:
<TextBlock Text="{Binding MyProperty,Converter={StaticResource converter}}" />
Run Code Online (Sandbox Code Playgroud)
但我不想这样做; 我只想绑定到datacontext而不是datacontext.MyProperty,如果你理解我的意思.
Mat*_*ton 32
只需省略路径:
<TextBlock Text="{Binding Converter={StaticResource converter}}" />
Run Code Online (Sandbox Code Playgroud)
等等 - 我注意到你的问题是用Silverlight标记的.这在Silverlight中不起作用吗?如果没有,您可能需要使用扩展语法:
<TextBlock>
<TextBlock.Text>
<Binding Converter="{StaticResource converter}" />
</TextBlock.Text>
</TextBlock>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
8074 次 |
最近记录: |