微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

开发一个选择器,以 xamarin 形式从所选框架向下弹出

如何解决开发一个选择器,以 xamarin 形式从所选框架向下弹出

我有一个要实现的设计。虽然我使用 Rg.plugin 已经有一段时间尝试不同的动画和输入行为,但它总是覆盖整个屏幕。

然而,我目前使用的设计是不同的。

这是图片

enter image description here

请有没有人知道我如何使用 xamarin 表单来实现这一点。 任何帮助将不胜感激。

注意,我已经使用 pancakeView 和 Rg.plugin 进行了设计,点击后将其弹出。然而,定位是我一直没能达到的。尽管我还没有为它编写任何代码,因为我更喜欢正确地进行研究。

请我需要任何人为我指出正确的道路或如何实现这一目标。

提前致谢

解决方法

根据你的截图,你可以使用entry和ListView做自定义控件来获取它,还有一个自定义控件你可以看看:

安装 Xamarin.Forms.EntryAutoComplete

使用此自定义控件,例如:

<ContentPage
x:Class="demo3.listviewsample.Page36"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:customControl="clr-namespace:EntryAutoComplete;assembly=EntryAutoComplete">
<ContentPage.Content>

    <StackLayout>
        <customControl:EntryAutoComplete
            ItemsSource="{Binding Countries}"
            MaximumVisibleElements="5"
            Placeholder="Enter country..."
            SearchMode="{Binding SearchMode}"
            SearchText="{Binding SearchCountry}"
            VerticalOptions="CenterAndExpand" />
    </StackLayout>

</ContentPage.Content>
 public class dialogvidemodel:ViewModelBase
{
    private string _searchCountry = string.Empty;
   
    private SearchMode _searchMode = SearchMode.Contains;

    public string SearchCountry
    {
        get => _searchCountry;
        set
        {
            _searchCountry = value;
            RaisePropertyChanged("SearchCountry");
        }
    }

    public List<string> Countries { get; } = new List<string>
    {
        "African Union","Andorra","Armenia","Austria","Togo","Turkey","Ukraine","USA","Wales"
    };

    public SearchMode SearchMode
    {
        get => _searchMode;
        set
        {
            _searchMode = value;
            RaisePropertyChanged("SearchMode");
        }
    }
}

更多详细信息,请看:

https://github.com/krzysztofstepnikowski/Xamarin.Forms.EntryAutoComplete

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。