Xamarin XAML 带有 ContentPage 和 IconImageSource 的 NavigationPage
Xamarin XAML NavigationPage with ContentPage and IconImageSource
我在 Xamarin Xaml 中为这种情况苦苦挣扎了 2 天,我无法从 MS 文档和 Whosebug 上找到任何帮助,也许我无法以正确的方式定义这个问题,这是我的问题:
如果我在 NavigationPage 中定义了另一个标签,我不知道如何在 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 上发布了一个 repo
https://github.com/mmassari/TestTabbedPageWithIcons
有办法实现吗?
谢谢
正如提示中提到的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>
我在 Xamarin Xaml 中为这种情况苦苦挣扎了 2 天,我无法从 MS 文档和 Whosebug 上找到任何帮助,也许我无法以正确的方式定义这个问题,这是我的问题: 如果我在 NavigationPage 中定义了另一个标签,我不知道如何在 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 上发布了一个 repo https://github.com/mmassari/TestTabbedPageWithIcons
有办法实现吗?
谢谢
正如提示中提到的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>