Bug 55315 - Xamarin.Forms Mac is open two windows
Summary: Xamarin.Forms Mac is open two windows
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Mac ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- blocker
Target Milestone: ---
Assignee: Jimmy [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-04-18 07:35 UTC by Daniel Hindrikes
Modified: 2017-04-24 16:38 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
My solution (378.32 KB, application/zip)
2017-04-18 07:35 UTC, Daniel Hindrikes
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Daniel Hindrikes 2017-04-18 07:35:13 UTC
# Steps to reproduce
Create a new Xamarin.Forms solution
Add a Mac project
Add latest -pre Xamarin.Forms(2.3.5.233-pre1) nuget package to mac project.
Update nuget package of Xamarin.Forms (2.3.5.233-pre1)

Update the AppDelegate.cs as in the blog post from Xamarin, https://developer.xamarin.com/guides/mac/user-interface/working-with-windows/

# Expected behavior
App will open a windows with the content created in the Xamarin.Forms project.

# Actual behavior
An empty windows is opened.

# Supplemental info (logs, images, videos)
If adding below rows, correct windows is open as well as the empty window. So the rendering of content working.

var controller = NSApplication.SharedApplication.MainWindow.WindowController as NSWindowController;
controller.ShowWindow(_window);

# Test environment (full version information)
=== Xamarin Studio Enterprise ===

Version 6.3 (build 863)
Installation UUID: 768e3a07-df1e-435a-b881-65109c4d7d88
Runtime:
	Mono 4.8.1 (mono-4.8.0-branch/22a39d7) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 408010000

=== NuGet ===

Version: 3.5.0.0

=== Xamarin.Profiler ===

Version: 1.4.0
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 8.3.1 (12170)
Build 8E1000a

=== Xamarin.iOS ===

Version: 10.8.0.175 (Visual Studio Enterprise)
Hash: a04678c2
Branch: d15-1
Build date: 2017-03-28 14:05:38-0400

=== Xamarin.Mac ===

Version: 3.2.0.175 (Visual Studio Enterprise)

=== Xamarin.Android ===

Version: 7.2.0.7 (Visual Studio Enterprise)
Android SDK: /Users/dhindrik/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.4   (API level 19)
		5.0   (API level 21)
		5.1   (API level 22)
		6.0   (API level 23)
		7.1   (API level 25)

SDK Tools Version: 25.2.5
SDK Platform Tools Version: 25.0.4
SDK Build Tools Version: 24.0.2

Java SDK: /usr
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Inspector ===

Version: 1.2.1
Hash: 0ea0a12
Branch: d15-1
Build date: Thu, 06 Apr 2017 20:24:44 GMT

=== Build Information ===

Release ID: 603000863
Git revision: a2163670efe259c85cd8f335d95b175068fbbe2a
Build date: 2017-04-03 14:33:15-04
Xamarin addins: 2045d688ea1420e0381b473360ca62a763eb7d04
Build lane: monodevelop-lion-d15-1

=== Operating System ===

Mac OS X 10.12.4
Darwin Daniels-MacBook-Pro-2.local 16.5.0 Darwin Kernel Version 16.5.0
    Fri Mar  3 16:52:33 PST 2017
    root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64
Comment 1 Daniel Hindrikes 2017-04-18 07:35:58 UTC
Created attachment 21584 [details]
My solution
Comment 2 Daniel Hindrikes 2017-04-18 07:51:53 UTC
If adding the lines below I got the same result with two windows. I tried those rows because I find them in the LoadApplication method when I took a look at the source code.

MainWindow.Display();
			MainWindow.MakeKeyAndOrderFront(NSApplication.SharedApplication);
Comment 3 Daniel Hindrikes 2017-04-18 08:15:26 UTC
It looks like the problem is that two windows are opened all the time. I first missed the second windows with the forms content, while I just expect it to be one window.
Comment 4 Jimmy [MSFT] 2017-04-24 16:38:01 UTC
When you create a macOS project to use with Forms, you will need to remove the default Main storyboard as the entry point in the info.plist file, otherwise both windows will be created at launch. Check out this blog post for a walk-through on how to set up a new macOS Forms project: https://blog.xamarin.com/preview-bringing-macos-to-xamarin-forms/