Xamarin导航栏具有不需要的默认图标,无法更改或删除 [英] Xamarin navigation bar has unwanted default icon, impossible to alter or remove
问题描述
最近我将Xamarin项目升级到了所有最新的DLL.现在,导航栏上的图标已出现在Android上(尚未查看iOS).看到通用图标:
Recently I upgraded my Xamarin project to all the latest DLLs. Now on the navigation bar an icon has appeared on Android (haven't looked at iOS yet). See generic icon:
花了数小时搜索和制作原型代码后,我仍然不知道如何更改或摆脱该图标!对我的项目中的png文件进行递归搜索找不到这样的图像.
After spending hours searching and prototyping code I still can't figure out how to change or get rid of the icon! Doing a recursive search for png files in my project finds no such image.
有一个方法SetTitleIcon,但是该方法没有执行任何操作.有人谈论布局文件夹中的工具栏xaml文件,但是我没有这样的文件.
There is a method SetTitleIcon but that method doesn't do anything. Some people talk about a toolbar xaml file in the layout folder, but I have no such file.
我遵循了本教程: https://xamarinhelp.com/xamarin-forms-toolbar/,但只能添加图标,它不会删除默认图标.
I followed this tutorial: https://xamarinhelp.com/xamarin-forms-toolbar/ but can only add icons, it doesn't remove the default icon.
我找到了这个演示项目: https://developer.xamarin.com /samples/monodroid/Supportv7/AppCompat/Toolbar ,但该代码与我的代码完全不同.我需要走那条路线吗?
I found this demo project: https://developer.xamarin.com/samples/monodroid/Supportv7/AppCompat/Toolbar but that code is quite different from mine. Do I need to go that route?
无论如何,我的主要xaml文件:
Anyway, my main xaml file:
<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:SharedMobile"
NavigationPage.HasNavigationBar="true"
x:Class="SharedMobile.MainPage">
<MasterDetailPage.Master>
<local:MainPageMaster x:Name="MasterPage" />
</MasterDetailPage.Master>
<MasterDetailPage.Detail>
<NavigationPage BarBackgroundColor="#DCDCDC">
<x:Arguments>
<local:ActionProcessesPage />
</x:Arguments>
</NavigationPage>
</MasterDetailPage.Detail>
</MasterDetailPage>
导航栏项目中的其他地方几乎没有提及.我确实尝试在导航页"下添加一个NavigationPage.Icon.什么都没发生.
There is little to no mention anywhere else in the project of a navigation bar. I did try to add a NavigationPage.Icon under the Navigation Page. Nothing happened.
我只兼职做Xamarin是我的借口.
I only do Xamarin part-time is my excuse.
推荐答案
我在Stack Overflow上发布的主要原因之一经常是(出于某种原因)发布后不久(我会找出答案).
One of the main reasons I post on Stack Overflow is often (for some reason) shortly after posting I will figure out or find the answer.
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:SharedMobile;assembly=MyApp.Mobile"
NavigationPage.TitleIcon="transparent.png"
x:Class="SharedMobile.ActionProcessesPage">
这篇关于Xamarin导航栏具有不需要的默认图标,无法更改或删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!