I'm struggling from 2 days with this situation in Xamarin Xaml and i can't find any help from MS documentation and here on stackoverflow maybe I can't define this problem in the right way, here is my issue: I can't figure out how I can set the ContentPage inside the NavigationPage if I have another tag defined inside.
In a standard TabbedTage i define my pages in this way:
<NavigationPage Title="Print Label" IconImageSource="{StaticResource Key=icon}">
<x:Arguments>
<local:PrintLabelsPage />
</x:Arguments>
</NavigationPage>
If I want to set a custom IconImageSource to use FontAwesome glyphs instead of bitmap image i use this techinque successfully:
<NavigationPage Title="Print Label">
<NavigationPage.IconImageSource>
<FontImageSource
FontFamily="FARegular"
Size="Large"
Glyph="{x:Static fa:Glyphs.ShoppingCart }" />
</NavigationPage.IconImageSource>
</NavigationPage>
But if I want both the feature i can't do it in any way:
<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>
I have published a repo on github https://github.com/mmassari/TestTabbedPageWithIcons
Is there a way to achieve this?
Thanks
CodePudding user response:
Just as the tip mentioned x:Argument cannot follow any other elements or cotent. Move the x:Arguments elements to be the first
, you can just move the x:Arguments
elements to be the first,just as follows:
<NavigationPage Title="TestSchedule" >
<x:Arguments>
<local:Page2 />
</x:Arguments>
<NavigationPage.IconImageSource>
<FontImageSource FontFamily="FARegular" Size="Large" Glyph="" />
</NavigationPage.IconImageSource>
</NavigationPage>
Not:
<NavigationPage.IconImageSource>
<FontImageSource FontFamily="FARegular" Size="Large" Glyph="" />
</NavigationPage.IconImageSource>
<x:Arguments>
<local:Page2 />
</x:Arguments>
</NavigationPage>