Apparently, this is because you only created some object and did not do anything else. How a application can "know" that you want to show it? You need to add an instance of your control in its parent content control.
Please see:
http://msdn.microsoft.com/en-us/library/system.windows.controls.contentcontrol.content.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.windows.window.aspx[
^] (
Window
is one of content controls.
You would be able to insert an instance of your control in the window directly, so your question would be answered, but it won't look good or be especially useful in practice. Normally, the content of a window is of some type of panels. And a panel would allow to add several controls, because it has the property
Children
of the type
UIElementCollection
:
http://msdn.microsoft.com/en-us/library/system.windows.controls.panel.children.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.windows.controls.uielementcollection.aspx[
^].
So, you would need to
Add
or
Insert
the instance of your control:
http://msdn.microsoft.com/en-us/library/system.windows.controls.uielementcollection.add.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.windows.controls.uielementcollection.insert.aspx[
^].
First thing you should understand in general is the WPF content model:
http://msdn.microsoft.com/en-us/library/bb613548.aspx[
^].
This should explain to you what to code should do. But also, you can simply add some controls, including yours, in XAML. With XAML, the code doing the same will be auto-generated during build of the project. This auto-generated code is not part of the project, this is a set of temporary *.cs files. If you want to see how this code looks like, you can find then inside the directory structure of your project sub-directory. They are not deleted after the build. So, this is my advice to see how things work: create a project with XAML, build it, find out auto-generated *.cs files and see what is written in them. This way, you can learn a lot of basics.
—SA