如何在xamarin.forms中使用3个按钮设计标题 [英] How to design header with 3 buttons in xamarin.forms
问题描述
我正在尝试设计类似whatsapp聊天页面的标题,其中在右侧我们有3个按钮进行搜索,呼叫和旋转..
I am trying to design header like whatsapp chat page where on right hand side we have 3 buttons search,call and carousal ..
我想使用xamarin.forms在contentPage中进行设计.
Same i want to design in contentPage using xamarin.forms.
我可以使用ToolbarItems添加旋转木马,但是如何添加其他两个按钮(搜索和呼叫)
I am able to add carousal by using ToolbarItems but how can i add other two button(search and call)
推荐答案
您可以使用工具栏项来实现此目的.只需添加其他项目即可.
You can use the toolbar items to achieve this. Just add additional items.
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ToolbarItems.Views.MainView">
<ContentPage.ToolbarItems>
<ToolbarItem Name="Menu1" Activated="OnClick" Order="Primary" Priority="0" />
<ToolbarItem Name="Menu2" Activated="OnClick" Order="Primary" Priority="1" />
</ContentPage.ToolbarItems>
</ContentPage>
如果将项目的Order
设置为Secondary
,则会将您的项目添加到菜单,如右侧的菜单(3个点).要实现外观,您可以创建类似以下内容的
If you set the Order
of the item to Secondary
your item gets added to a menu like the one on the right hand side (the 3 dots). To achieve your look you would create something like this:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ToolbarItems.Views.MainView">
<ContentPage.ToolbarItems>
<ToolbarItem Name="Search" Order="Primary" Priority="0" />
<ToolbarItem Name="Call" Order="Primary" Priority="1" />
<ToolbarItem Name="Additional1" Order="Secondary" Priority="0" />
<ToolbarItem Name="Additional2" Order="Secondary" Priority="1" />
</ContentPage.ToolbarItems>
</ContentPage>
这将创建与您在Android上想要的东西非常接近的东西.在iOS上,这看起来有些不同.如果要获得相似的外观,则必须使用自定义渲染器.
This will create something pretty close to what you want on Android. On iOS however this looks a bit different. If you want to achieve a similar look you will have to resort to custom renderers.
这篇关于如何在xamarin.forms中使用3个按钮设计标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!