Pages

Showing posts with label Error The object 'Window' already has a child and cannot add 'Grid'. 'Window' can accept only one child. Show all posts
Showing posts with label Error The object 'Window' already has a child and cannot add 'Grid'. 'Window' can accept only one child. Show all posts

Wednesday, July 17, 2013

Error The property "Content" can only be set once, Error The object 'Window' already has a child and cannot add 'Grid'. 'Window' can accept only one child.

Exception Message

Error The property "Content" can only be set once.

Error The object 'Window' already has a child and cannot add 'Grid'. 'Window' can accept only one child.


Cause and Resolution

The Parent <window> </window> can have only one child element. for e.g:-

<window>
     <grid>
    </grid>
    <grid>
    </grid>
</window>

Is wrong instead we should have like this

<window>
    <grid>
            <grid>
            </grid>
            <grid>
            </grid>
   </grid>
</window>

The child element that is added doesnt necessarily be gird it can be stackpanel , dockpanel or canvas etc.