我在 Xamarin Xaml 中遇到這種情況已經有 2 天了,我無法從 MS 檔案中找到任何幫助,在 stackoverflow 上也許我無法以正確的方式定義這個問題,這是我的問題:我不能如果我在其中定義了另一個標簽,請弄清楚如何在 NavigationPage 中設定 ContentPage。
在標準的 TabbedTage 中,我以這種方式定義我的頁面:
<NavigationPage Title="Print Label" IconImageSource="{StaticResource Key=icon}">
<x:Arguments>
<local:PrintLabelsPage />
</x:Arguments>
</NavigationPage>
如果我想設定一個自定義 IconImageSource 來使用 FontAwesome 字形而不是位圖影像,我成功地使用了這個技術:
<NavigationPage Title="Print Label">
<NavigationPage.IconImageSource>
<FontImageSource
FontFamily="FARegular"
Size="Large"
Glyph="{x:Static fa:Glyphs.ShoppingCart }" />
</NavigationPage.IconImageSource>
</NavigationPage>
但是,如果我想要這兩個功能,我就無法以任何方式做到:
<NavigationPage Title="Print Label">
<NavigationPage.IconImageSource>
<FontImageSource
FontFamily="FARegular"
Size="Large"
Glyph="{x:Static fa:Glyphs.ShoppingCart }" />
</NavigationPage.IconImageSource>
<x:Arguments>
<local:PrintLabelsPage />
</x:Arguments>
</NavigationPage>
我已經在 github https://github.com/mmassari/TestTabbedPageWithIcons上發布了一個 repo
有沒有辦法實作這一目標?
謝謝
uj5u.com熱心網友回復:
正如提示中提到的x:Argument cannot follow any other elements or cotent. Move the x:Arguments elements to be the first,您可以將x:Arguments元素移動到第一個,如下所示:
<NavigationPage Title="TestSchedule" >
<x:Arguments>
<local:Page2 />
</x:Arguments>
<NavigationPage.IconImageSource>
<FontImageSource FontFamily="FARegular" Size="Large" Glyph="" />
</NavigationPage.IconImageSource>
</NavigationPage>
不是:
<NavigationPage.IconImageSource>
<FontImageSource FontFamily="FARegular" Size="Large" Glyph="" />
</NavigationPage.IconImageSource>
<x:Arguments>
<local:Page2 />
</x:Arguments>
</NavigationPage>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/363511.html
