Forum Xamarin.iOS


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Is MvvvmCross compatible with iOS's SceneDelegate? I get a black screen when using UITableView

UnreachableCodeUnreachableCode USMember ✭✭✭
edited February 15 in Xamarin.iOS

I've searched this online, and so far can't find any article mentioning MvvmCross + SceneDelegate.

In my SceneDelegate, I do the following:

        public void WillConnect(UIScene scene, UISceneSession session, UISceneConnectionOptions connectionOptions)
            // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
            // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
            // This delegate does not imply the connecting scene or session are new (see UIApplicationDelegate `GetConfiguration` instead).

            Window = new UIWindow(UIScreen.MainScreen.Bounds);
            //Assign the current scene to the Window instance [NEW CODE NEEDED]

            if (Window != null)
                Window.WindowScene = (UIWindowScene)scene;
                // Assign the root view controller
                Window.RootViewController = new ItemListViewController();
                // Make the window visible

And in AppDelegate, I have far less code than usual thanks to the new SceneDelegate:

    public class AppDelegate : MvxApplicationDelegate<MvxIosSetup<App>, App> 
        public override UIWindow Window { get; set; }

        // FinishedLaunching is the very first code to be executed in your app. Don't forget to call base!
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
            var result = base.FinishedLaunching(application, launchOptions);

            return result;

Finally, I have this ViewController with a TableView:

public partial class ItemListViewController : MvxViewController
public ItemListViewController() : base("ItemListViewController", null)

    public override void ViewDidLoad()
        // Perform any additional setup after loading the view, typically from a nib.

        NavigationItem.Title = "Item List";

        var source = new MvxSimpleTableViewSource(ItemTableView, "ItemViewCell", ItemViewCell.Key);
        ItemTableView.RowHeight = 130;

        var set = this.CreateBindingSet<ItemListViewController, ItemsViewModel>();
        set.Bind(source).To(vm => vm.Items);

        ItemTableView.Source = source;


But for some reason, I'm getting a black screen when using this code. No error is being thrown up, but I can't help but think it's an issue with setting my RootViewController in SceneDelegate. I can't find documentation on the MvvmCross site for how I'm properly supposed to do this. All the older articles point to MvxIosSetup, but the overrides and constructors are significantly different from the ones documented. Has anyone encountered this issue before?

Sign In or Register to comment.