【发布时间】:2021-07-03 17:57:48
【问题描述】:
我的ListView 绑定到MyTexts 列表。尽管如此,我需要将TextCell's Text 绑定到不是来自Texts (StandAloneProperty) 的属性。我该怎么做?
<ListView
SelectedItem="{Binding SelectedText, Mode=TwoWay}"
ItemsSource="{Binding MyTexts}">
<ListView.ItemTemplate>
<DataTemplate>
<TextCell
Text="{Binding StandAloneProperty, StringFormat='Value: {0}'}"
TextColor="{Binding Color}"
/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
【问题讨论】:
-
StandAloneProperty在哪里定义?它是在与MyTexts相同的基础虚拟机上还是在其他地方?你读过Relative Bindings吗? -
@Jason 它位于同一个虚拟机中
-
参见上述链接文档中的“绑定到祖先”示例
标签: xaml xamarin xamarin.forms data-binding