我将prism sample here扩展为还包括图标和一些其他导航。我的目标是添加类似下面的代码(其中的图标信息在其中),并且不确定如何将其正确添加到我的视图或视图模型中。
<?xml version="1.0" encoding="UTF-8"?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:WebOfTrust.Views"
x:Class="WebOfTrust.Views.Client.WebOfTrustMainPage"
Title="{Binding Title}">
<TabbedPage.Children>
<!-- HOW DO I SET AN ICON FOR THESE? Either in the View or Model? -->
<NavigationPage Title="Contacts" >
<x:Arguments>
<local:Client.MyPeople.MyPeopleList/>
</x:Arguments>
</NavigationPage>
<NavigationPage Title="Places" Icon="Image7DoesntWork.png">
<x:Arguments>
<local:Client.MyPlaces.MyPlacesList/>
</x:Arguments>
</NavigationPage>
<NavigationPage Title="Docs" Icon="Image7DoesntWork.png">
<x:Arguments>
<local:Client.MyWallet.WalletCards/>
</x:Arguments>
</NavigationPage>
</TabbedPage.Children>
</TabbedPage>
正常工作
我通常在视图中有一个导航页面,在其中指定以下图标。
<NavigationPage Title="Trust Anchor List">
<NavigationPage.Icon>
<OnPlatform x:TypeArguments="FileImageSource">
<On Platform="iOS" Value="tab_feed.png"/>
</OnPlatform>
</NavigationPage.Icon>
<x:Arguments>
<local:Client.TrustAnchorList />
</x:Arguments>
</NavigationPage>
问题
使用Prism 时,在视图或模型中设置图标的正确方法是什么?
答案 0 :(得分:0)
只需在选项卡式页面的子级中添加icon属性。 对我来说很好
<local:ContactUs Icon="Icons/History_Tab.png" Title="{Translate:TranslateExtension Text=NewMessage}" />
我的图标位于资源中的文件夹下,但您可以将它们放置在任何位置。