如何在 Xamarin 表单中自定义导航栏中的搜索栏 [英] How to customize search bar in navigation bar in Xamarin forms

查看:55
本文介绍了如何在 Xamarin 表单中自定义导航栏中的搜索栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在 Xamarin.android 和 Xamarin.Ios 的导航栏中添加搜索栏.我已经尝试了下面的帖子它正在工作'但我想在其中自定义搜索栏文本颜色和搜索栏图像.你能提出任何想法吗.

我尝试过链接:

当我应用上面的链接代码时,我得到了这样的导航栏,当用户点击搜索图片时,搜索栏将出现在导航栏中.在上面的导航栏点的图像是工具栏图像设置顺序是主要".我的要求是先显示搜索图像,然后在显示工具栏图像后,将搜索图像的位置与上图中的条形图像完全交换.我怎样才能做到这一点.

解决方案

您使用 ToolbarItem 的 Priority 属性来定义从左到右的顺序,而不是 Ordering 属性.我知道,一点都不迷惑!

<ToolbarItem Name="SearchItem" Icon="search.png" Priority="0"/><ToolbarItem Name="MoreItem" Icon="more.png" Priority="1"/></ContentPage.ToolbarItems>

阅读这篇关于 Xamarin 表单工具栏的精彩博文,了解更多详情

I am try to add search bar in navigation bar in both Xamarin.android and Xamarin.Ios. I have tried the below post it's working ' but I want to customise the searchbar text color and search bar image in that. Can you please suggest any idea.

I am tried link : https://www.linkedin.com/pulse/xamarin-forms-contentpage-searchbar-navigation-bar-vipin-mathews

When I apply above link code I am getting navigation bar like this and when user click on search image, search bar will be appear in navigation bar. In the above navigation bar dot's image is a toolbar images set order is 'Primary'. My requirement is show search image first then after showing the toolbar image, exactly swap the position's of search image too bar image in the above image. How can I achieve that.

解决方案

You use the Priority property of the ToolbarItem to define the left to right order, not the Ordering property. I know, not confusing at all!

<ContentPage.ToolbarItems>
    <ToolbarItem Name="SearchItem" Icon="search.png" Priority="0" />
    <ToolbarItem Name="MoreItem" Icon="more.png" Priority="1" />
</ContentPage.ToolbarItems>

Read this great blog post about the Xamarin Forms Toolbar for more details

这篇关于如何在 Xamarin 表单中自定义导航栏中的搜索栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆