You have a WPF application. You have a class such as a UserControl defined using XAML. You derive a class from the UserControl.
<CheckBox Height="16" Margin="8,30,0,0" Name="checkBox1" VerticalAlignment="Top" HorizontalAlignment="Left" Width="120">CheckBox</CheckBox>
You need to define your base class all in code without using XAML.
Your derived class is not instantiated in the designer when you are designing it, which means that any calls made to your base class from the constructor are not called. Furthermore, if you try to initialize your base class's content in its constructor, you will find that Content member is still set to null.
This results in that your base class's content does not show up in the designer when you are designing your deriving class, even though it does at runtime.
One way to workaround is to add code similar to the one below in your base class:
public class UserControlInCode : UserControl
protected override void OnContentChanged(object oldContent, object newContent)
StackPanel panel = new StackPanel();
Button button = new Button();
button.Content = "Test";
This way, you wait until your base class sets Content member.
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, MICROSOFT AND/OR ITS SUPPLIERS DISCLAIM AND EXCLUDE ALL REPRESENTATIONS, WARRANTIES, AND CONDITIONS WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO REPRESENTATIONS, WARRANTIES, OR CONDITIONS OF TITLE, NON INFRINGEMENT, SATISFACTORY CONDITION OR QUALITY, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE MATERIALS.
Article ID: 957231 - Last Review: Aug 26, 2008 - Revision: 1