Question: I have the following `MainWindow` class:

```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace mylibrary
{
    public class MainWindow : Window
    {
        WorkSpaceView ws;
        public MainWindow()
            : base()
        {
            ws = new WorkSpaceView();
        }

    }
}

```

In above code `WorkSpaceView` is a wpf user control. I need to add this user control to the `MainWindow`. But I don't know how!? Could you please guide me how should I add and show a user control inside a window, dynamically?

Answer: 
A WPF window has a [`Content` property.](https://msdn.microsoft.com/en-us/library/system.windows.controls.contentcontrol.content(v=vs.110).aspx)

Typically, a WPF control that can have only one child or content item has this property.

If it can have multiple, it will likely use the `Children` property.

adding your control to the window should be as simple as :

```
public class MainWindow : Window
{
    WorkSpaceView ws;
    public MainWindow()
        : base()
    {
        ws = new WorkSpaceView();
        this.Content = ws;
    }

}

```
If you have a grid in your xaml file then you can do something like 

```
 var myUsercontrol= new WorkSpaceView ();
 MyGrid.Children.Add(myUsercontrol);

```