简体   繁体   English

Xamarin形成主细节图标

[英]Xamarin forms Master detail Icon

I am trying to add an image next to the hamburger menu in my app. 我正在尝试在我的应用中的汉堡菜单旁边添加图片。 I am using a master detail page and it renders fine in ios and android. 我正在使用主详细信息页面,它在ios和android中可以正常显示。 I tried using setting the icons for the detail pages. 我尝试使用设置详细信息页面的图标。 but the icons never showed. 但图标从未显示。 How do I achive this. 我如何做到这一点。 I am looking to add an image similar to the amazon app. 我正在寻找添加类似于亚马逊应用程序的图像。

在此处输入图片说明

I checked out this app on my phone and it uses a lot of custom constructions that aren't supported by out of the box Xamarin Forms controls. 我在手机上签出了该应用程序,它使用了许多自定义构造,而Xamarin Forms控件不提供现成的支持。 Something like the back arrow next to the hamburger menu is not a standard thing (on iOS at least). 汉堡菜单旁边的向后箭头之类的东西不是标准的东西(至少在iOS上是这样)。 Also looking at the actual menu that the hamburger button triggers it becomes clear that its not an out of the box hamburger menu. 同时查看汉堡按钮触发的实际菜单,很明显它不是开箱即用的汉堡菜单。 Theirs pops over the content instead of sliding it out of view as the built-in one does. 他们弹出内容,而不是像内置内容那样将其滑出视图。

More than likely they implemented their own hamburger menu and navigation structure which gave them the freedom to add buttons next to it. 他们极有可能实现了自己的汉堡菜单和导航结构,使他们可以自由地在其旁边添加按钮。 If you want to achieve this with out of the box controls you will most likely need custom renderers for each platform to create a replica of this navigation structure. 如果要使用开箱即用的控件来实现此目的,则很可能需要为每个平台使用自定义渲染器来创建此导航结构的副本。

What is built-in in Xamarin Forms is that you can set the page title to an image instead of text by using the NavigationPage.SetTitleIcon method, which could be used to achieve what you want: 什么内置在Xamarin形式是,你可以通过设置页面标题图片代替文字NavigationPage.SetTitleIcon方法,它可以用来实现你想要的:

public class MyPage : NavigationPage
{
    public MyPage ()
    {
        var myContentPage = new MyContentPage (Color.White);
        this.Push (myContentPage);

        var s = "icon.png";
        NavigationPage.SetTitleIcon (myContentPage, s);
    }
}

Even then, this is limited in functionality. 即使这样,功能也受到限制。 If you want to fiddle with the alignment of the image eg you would also need to resort to a custom renderer. 如果您想弄乱图像的对齐方式,例如,您还需要使用自定义渲染器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM