如何在帶有 Shell 的 Xamarin Forms 應用程式的選項卡中使用圖示,例如 Material Icons 而不是 PNG iamges?
以下是我在 Xamarin Forms 應用程式中為主螢屏定義選項卡的方式:
<FlyoutItem Title="Home">
<FlyoutItem.Icon>
<FontImageSource
FontFamily="MISHRP"
Glyph="{StaticResource HomeIcon}"
Color="White" />
</FlyoutItem.Icon>
<Tab Title="Dashboard" Icon="icon_dashboard.png">
<ShellContent Route="Dashboard" ContentTemplate="{DataTemplate views:Dashboard}" />
</Tab>
<Tab Title="My Feed" Icon="{StaticResource Feed}">
<ShellContent Route="MyFeed" ContentTemplate="{DataTemplate views:MyFeed}"/>
</Tab>
</FlyoutItem>
正如您在上面的代碼中看到的,在第一個選項卡項(儀表板)中,我使用了一個 PNG 影像,它在我的應用程式中顯示良好。
在第二個選項卡項(我的提要)中,我嘗試使用我在App.xaml頁面中定義的圖示,但根本沒有顯示。
如何在 Shell Xamarin Forms 應用程式的選項卡中使用圖示?
uj5u.com熱心網友回復:
我認為您使用類似這樣的東西,來自 MyCoffeeApp
https://github.com/jamesmontemagno/MyCoffeeApp/blob/master/MyCoffeeApp/MyCoffeeApp/AppShell.xaml
<Tab.Icon>
<FontImageSource FontFamily="FAS"
Color="{AppThemeBinding
Dark=White,
Light={StaticResource SystemGray5Dark}}"
Glyph="{StaticResource IconCoffee}"/>
</Tab.Icon>
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/459769.html
