The purpose of this post is to show you how to declare and use a specific user control in Silverlight. To do this I'll use a simple example of a Wizard page containing user control representing steps.
Here is the corresponding class diagram:

In our example each wizard step is a “UserControl” type “WizardControl” that is to say; it contains the method “Next” and “Previous” as defined in the interface “IWizardControl”.
How do I create it step by step?
Step 1: Create the base class
public class WizardControl : UserControl, IWizardControl
{
public virtual void Next() { }
public virtual void Previous() { }
}
Step 2: Initialization in XAML
<src:WizardControl x:Class="UserControlInheritance.WizardStep1"
xmlns:src="clr-namespace:UserControlInheritance.Controls"
</src:WizardControl>
Step 3: in the code behind, we inherit WizardControl
public partial class WizardStep1 : UserControlInheritance.Controls.WizardControl
{
public WizardStep1()
{
InitializeComponent();
}
public override void Next()
{
base.Next();
MessageBox.Show(String.Format("Hello {0}", NameTextBox.Text));
}
public override void Previous()
{
base.Previous();
}
}
Use of the user controls
And finally, as a result, we can create a wizard with a list of the different steps. Like this:
wizard = new List<WizardControl>()
{
new WizardStep1(),
new WizardStep2()
};
WizardControl currentControl = contentControl.Content as WizardControl;
contentControl.Content = controls[currentIndex];
And here is the "visual" result:

Full source code here: