Steps for creating your UserControl from your derived class

|  Posted: February 28, 2010  |  Categories: General Technical

When you start learning Silverlight or even to some extend on a medium size project, you’ll be fine with deriving your user controls directly from System.Windows.Controls.UserControl. But soon you’ll be in a situation to derive your user controls from your own custom user control to keep something consistent. Here are the steps

Step 1:

Create a custom user control derived from System.Windows.Controls.UserControl. Ex:

public class EnvironmentAwareUserControl : UserControl


public EnvironmentSettings EnvironmentSettings { get; set; }


Step 2:

Once you added a new Silverlight User Control to your project, change it to


public partial class SilverlightControl1 : UserControl


public partial class SilverlightControl1 : EnvironmentAwareUserControl

Step 3:

This is the confusing bit (or the way Silverlight/WPF works). You need the change the XAML as well to reflect that you are deriving it from a custom control.

from :

<UserControl x:Class=”Test.UI.SilverlightControl1″


<EnvironmentAwareUserControl x:Class=”Test.UI.SilverlightControl1″


<local:EnvironmentAwareUserControl x:Class=”Test.UI.SilverlightControl1″

depending on your namespace declaration.

Common Error message you’ll see when you try to figure out this “Partial declarations of must not specify different base classes



Author: Saravana Kumar

Saravana Kumar is the Founder and CEO of BizTalk360 | Serverless360 | Atomic Scope | Document360. Founder of multiple B2B products that solve the pain point of enterprise customers. Entrepreneur, Investor, and Technical enthusiast. Passionate about running and scaling a company in a profitable way with calculated risks.

Back to Top