【问题标题】:How to Manage Tabs in Tabbedpage from ViewModel如何从 ViewModel 管理 Tabbedpage 中的选项卡
【发布时间】:2019-08-22 19:49:44
【问题描述】:

我正在开发应用程序,我必须在 TabbedPage 中动态创建/删除选项卡。

假设我有练习,每个练习都必须有自己的页面。当我通过构造函数传递锻炼视图模型时,我可以在后面的代码中创建选项卡,其余代码在视图模型中。用户可以添加或删除一些选项卡必须更改的练习。

如何从 ViewModel 管理 tabbedPage 中的选项卡?这个 ViewModel 就是这个页面中的 BindingContext。

【问题讨论】:

    标签: xamarin xamarin.forms


    【解决方案1】:

    如何从 ViewModel 管理 tabbedPage 中的选项卡?这个 ViewModel 就是这个页面中的 BindingContext。

    如果你想使用 ViewModel 在 Tabbedpage 中显示选项卡,我认为你可以将 DataTemplate 分配给 ItemTemplate 属性以返回集合中对象的页面。

    喜欢这个示例:

    https://github.com/xamarin/xamarin-forms-samples/tree/master/Navigation/TabbedPage

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-11
      • 2018-05-05
      • 2018-07-17
      • 2022-01-08
      • 2015-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多