【发布时间】:2019-10-03 10:31:47
【问题描述】:
我想将 viewmodel 绑定到 xamarin prism 框架中的嵌套选项卡视图
我创建了 4 个主页(A、B、C、D)作为主选项卡,在第一个选项卡(A)内我创建了另外两个选项卡(A1、A2)。但是嵌套选项卡的数据没有绑定。甚至视图模型意见(A1,A2)没有命中
MenuPage.xml
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyApp.Views.MenuPage"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
xmlns:b="clr-namespace:Prism.Behaviors;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"
xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
xmlns:views="clr-namespace:MyApp.Views"
BarBackgroundColor="White"
android:TabbedPage.ToolbarPlacement="Bottom"
NavigationPage.HasNavigationBar="True">
<TabbedPage.Children>
<views:A Title="A" Icon="abc.png" />
<views:B Title="B" Icon="abc.png" />
<views:C Title="C" Icon="abc.png" />
<views:D Title="D" Icon="abc.png"/>
</TabbedPage.Children>
</TabbedPage>
我的页面 A 是这样的
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:MyApp.Views"
x:Class="MyApp.Views.A">
<!--Pages can be added as references or inline-->
<TabbedPage.Children>
<views:A1 Title="A1" />
<views:A2 Title="A2" />
</TabbedPage.Children>
</TabbedPage>
我有 A1 和 A2 的单独视图模型。
因此,如果我直接将 A1 绑定到主导航页面,它将正常工作并呈现数据。但是如果我喜欢上面的视图模型,A1 不会击中构造函数,并且除了静态数据之外没有任何内容显示。我是标签页的新手导航。感谢任何帮助。这是我正在尝试实现的视图
【问题讨论】:
-
您有什么样的要求?为什么需要嵌套 TabbedPages!?
-
@G.hakim 我将图像添加到我的问题中我想要实现的目标..
-
我不认为这些是嵌套的标签视图
-
@G.hakim 你对如何实现这个有什么建议吗
-
您可以在网格中创建上述内容,并可以在单击时将内容视图添加到网格
标签: xamarin mvvm xamarin.forms prism tabbedpage