任何人都可以建議如何添加影像ContentPage IconImageSource?試圖在標題欄中顯示“icon.png”。ToolbarItem 中的影像“toolbar_icon.png”能夠顯示。兩個圖示都放在 Android Resources drawable 檔案夾中。iOS平臺還沒試過。
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="HelloWorld.Views.AboutPage"
Title="{Binding Title}"
IconImageSource="icon.png">
<ContentPage.ToolbarItems>
<ToolbarItem IconImageSource="toolbar_icon.png"></ToolbarItem>
</ContentPage.ToolbarItems>
</ContentPage>
App.xml 檔案是默認檔案,不會更新它。
<Shell xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:HelloWorld.Views"
Title="HelloWorldApp"
x:Class="HelloWorldApp.AppShell">
<TabBar>
<ShellContent Title="About" Icon="icon_about.png" Route="AboutPage" ContentTemplate="{DataTemplate local:AboutPage}" />
</TabBar>
</Shell>
謝謝。
uj5u.com熱心網友回復:
我們可以使用Shell.TitleView作為解決方法。
<Shell.TitleView>
<Image Source="icon_feed.png"
HorizontalOptions="Center"
VerticalOptions="Center" />
</Shell.TitleView>

參考
https://stackoverflow.com/a/58969359/8187800。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/313146.html
標籤:沙马林 xamarin.forms
