Xamarin.forms 如何在Prism for Xamarin窗体的Prism中为选项卡页设置图标属性?
我将扩展到包括图标和一些附加导航。我的目标是添加类似下面的代码(图标信息所在的位置),我不确定如何正确地将其添加到我的视图或视图模型中Xamarin.forms 如何在Prism for Xamarin窗体的Prism中为选项卡页设置图标属性?,xamarin.forms,prism,prism-6,tabbedpage,Xamarin.forms,Prism,Prism 6,Tabbedpage,我将扩展到包括图标和一些附加导航。我的目标是添加类似下面的代码(图标信息所在的位置),我不确定如何正确地将其添加到我的视图或视图模型中 <?xml version="1.0" encoding="UTF-8"?> <TabbedPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
<?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时,在视图或模型中设置图标的正确方法是什么
只需在选项卡页面的子项中添加图标属性即可。 这对我来说很好
<local:ContactUs Icon="Icons/History_Tab.png" Title="{Translate:TranslateExtension Text=NewMessage}" />
我的图标在参考资料中的一个文件夹下,但是你可以把它们放在任何地方。谢谢,我使用的是TypeArguments,对此我感到非常困惑。你知道这是怎么回事吗?而且你对翻译扩展的使用似乎很有趣。。您是否将其用于国际化?TypeArguments只是传递给您正在调用的构造函数或方法的参数。这是通过UI传递参数的XAML方式。TranslateExtension用于本地化,并根据设置的区域性动态显示文本。当我使用上面更新的另一个导航页面时,这似乎不起作用。我不确定为什么要将导航页面作为根添加到选项卡式页面?如果根页面是导航页面,并且它将继承导航栏和“后退”按钮,则只需按下选项卡式页面。