【发布时间】:2019-10-23 14:37:58
【问题描述】:
我正在尝试将文本从我的 Shell.SearchHandler 推送到命令。
我已经用 SearchBar 构建了它,但我需要它在 Shell.SearchHandler
中工作<Shell.SearchHandler >
<SearchHandler x:Name="searchBar"
Placeholder="Search..."
Command="{Binding PerformSearch}"
CommandParameter="{Binding Text, Source={x:Reference searchBar}}" TextColor="Black" BackgroundColor="LightGray" />
</Shell.SearchHandler>
在我的视图模型中
public ICommand PerformSearch => new Command<string>((string query) =>
{
//do work
});
命令执行,但查询参数始终为空。
如何将输入到 searchandler 中的文本发布到绑定命令?
【问题讨论】:
-
可以设置
Query,。Query="{Binding xxx,Mode=OneWayToSource}",并获取 ViewModel 中的值。
标签: xamarin xamarin.forms