0
我想为传递其他绑定值的转换器参数传递模型属性值。Xamarin Forms将模型值传递给绑定转换器参数
<Label FontSize="{Binding MediumLabelTextSize}"
Text="{Binding FeedHome.QuestionBody,
Converter={StaticResource HideLongTextConverter}}"/>
<Label FontSize="{Binding SmallLabelTextSize}"
IsVisible="{Binding IsQuestionReadMoreVisible}"
Text="Read more">
<Label.GestureRecognizers>
<TapGestureRecognizer Command="{Binding ReadMoreCommand}"
CommandParameter="{Binding .}"/>
</Label.GestureRecognizers>
</Label>
我想通过FeedHome.QuestionBody像IsQuestionReadMoreVisible转换器参数。 我该怎么办?
技术观点不应该发布一些东西来查看模型。 Command和CommandParameter是唯一的例外。如果你的视图中有数据,Viewmodel应该已经注意到了这一点 – Emad
IsVisible =“{Binding IsQuestionReadMoreVisible,ConverterParameter = {Binding Source = {x:Reference LabelName},Path = Text}}”这也可以,否则你可以使用传递BindingContext,如“{Binding BindingContext.FeedHome.QuestionBody,Source = {x:Reference MainPage}}” – Dilmah
为什么你不在你的viewModel中的ReadMoreCommand中使用你的FeedHome.QuestionBody属性?当点击标签时,你知道这个属性的价值,或不? – puko