P.T*_*agu 7 xamarin.forms visual-studio-2017
如何在 Xamarin 表单中使用 ComboBox,因为 xamarin 表单没有 ComboBox 控件,在我的应用程序中,我想显示国家/地区列表,以便用户可以双向选择国家/地区(搜索和下拉列表),给我解决此问题的建议注意:我找到了一种解决方案 syncfusion 组合框,但那是付费服务,我不想要付费服务
您可以使用xamarin上的Picker控件来实现在框中列出一些对象。我建议您遵循 MVVM 模式来绑定数据源和处理事件。有Microsoft 创建的代码示例。
但基本上你必须Picker
在你的 xaml 中添加一个:
<StackLayout Margin="20">
<Label Text="Bindable Picker Demo" FontAttributes="Bold" HorizontalOptions="Center" />
<Picker Title="Select a country" ItemsSource="{Binding CountryList}" SelectedItem="{Binding SelectedColorName, Mode=TwoWay}" />
</StackLayout>
Run Code Online (Sandbox Code Playgroud)
在您的模型中,只需设置您的Countrylist
属性,它就是选定的项目。
public IList<string> CountryList
{
get
{
return new List<string> {"USA","Germany","England"};
}
}
Run Code Online (Sandbox Code Playgroud)
如果你想在你的系统中进行搜索,Picker
你必须创建你自己的控件。根据您的意愿,一个Entry
和一个Listview
可能就足够了。您必须在TextChanged
入境时更新您的名单。
归档时间: |
|
查看次数: |
24215 次 |
最近记录: |