在片段中显示对话框片段

时间:2015-06-11 12:43:09

标签: android xamarin xamarin.android

如何在MvxFragment中显示MvxDialogFragment。不能使用FragmentMaganer等解决方案。

没有工作

public void ShowFragmentLatestInvoices()
    {

        var transaction = FragmentManager.BeginTransaction();
        var Manager = FragmentManager.BeginTransaction ();
        LatestInvoicesFragment LatestInvoicesFragment = new LatestInvoicesFragment();
        LatestInvoicesFragment.DataContext = ViewModel.InvoiceVM;
        LatestInvoicesFragment.Show(SupportFragmentManager, "LatestInvoices_fragment");


        OnAttachFragment (LatestInvoices);
    }

2 个答案:

答案 0 :(得分:1)

您可以通过Activity从片段中获取getActivity(),这样就可以了 您片段中的getActivity().getSupportFragmentManager()

答案 1 :(得分:1)

创建private MvxFragmentActivity myContext;

添加myContext = (MvxFragmentActivity)this.Activity;

并将SupportFragmentManager替换为myContext.SupportFragmentMannager

var FragmentTransactions = FragmentManager.BeginTransaction ();
            var transaction = FragmentManager.BeginTransaction();
            var Manager = FragmentManager.BeginTransaction ();
            LatestInvoicesFragment LatestInvoicesFragment = new LatestInvoicesFragment();
            LatestInvoicesFragment.Show(myContext.SupportFragmentManager, "LatestInvoices_fragment");