private XamlDomObject CreateXamlDom(XDocument xDocument)
        {
            _document = xDocument;
            var schemaContext = new XamlSchemaContext();

            var rootObjectsTag = GetElementWithMatchingAttribute(xDocument.Root.Element(XName.Get("data")), "key", "IBDocument.RootObjects");
            var windowTag      = GetElementWithMatchingAttribute(rootObjectsTag, "class", "IBUIWindow");

            XamlDomObject rootDomObject;

            if (windowTag != null)
            {
                rootDomObject = ViewHandler.CreateObject(windowTag, schemaContext)[0];
            }
            else // No window so there's one or more views
            {
                rootDomObject = new XamlDomObject(schemaContext.GetXamlType(typeof(UserControl)));
                var canvas = new XamlDomObject(schemaContext.GetXamlType(typeof(Canvas)));

                // TODO: We should make the DOM handle string based lookup of content here correctly.  Null refs currently
                rootDomObject.MemberNodes.Add(
                    new XamlDomMember(schemaContext.GetXamlType(typeof(UserControl)).ContentProperty, canvas));
                var canvasChildrenMember = new XamlDomMember(schemaContext.GetXamlType(typeof(Canvas)).ContentProperty);
                canvas.MemberNodes.Add(canvasChildrenMember);

                foreach (var viewTag in from objectTag in rootObjectsTag.Elements()
                         let attriNode = objectTag.Attribute(XName.Get("class"))
                                         where attriNode != null
                                         select objectTag)
                {
                    if (viewTag.Attribute(XName.Get("class")).Value == "IBProxyObject" ||
                        viewTag.Attribute(XName.Get("class")).Value == "IBUICustomObject")
                    {
                        continue;
                    }
                    ViewHandler.AddControlToTree(canvasChildrenMember, viewTag);
                }
            }

            // Scale to make it the right dimensions
            rootDomObject.MemberNodes.Add(
                new XamlDomMember(rootDomObject.Type.GetMember("RenderTransform"),
                                  new XamlDomObject(typeof(ScaleTransform),
                                                    new XamlDomMember("CenterX", (IPHONE_WIDTH / 2).ToString()),
                                                    new XamlDomMember("CenterY", (IPHONE_HEIGHT / 2).ToString()),
                                                    new XamlDomMember("ScaleX", WIDTHMULTIPLIER.ToString()),
                                                    new XamlDomMember("ScaleY", HEIGHTMULTIPLIER.ToString()))));

            WireNamesAndEvents(rootDomObject, xDocument);

            return(rootDomObject);
        }