I have a silverlight custom control named "BASE". I have another control that inherits from this class, "CHILD1". BASE has a ContentPresenter that holds the content from the CHILD1 control. I need to access a TextBox that is in the content of the CHILD1 control, it initiailzes, and displays, but it is always null in the code.
Is there a way to access these controls directly instead of iterating over the children collection of the content property?
Thanks.
CHILD1:
<local:BASE x:Class="CWTest1.CHILD1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:local="clr-namespace:CWTest"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400"
Height="300">
<Grid x:Name="LayoutRoot2"
Background="White">
<TextBox x:Name="tbx1"
Text="xx" />
</Grid>
public partial class CHILD1 : BASE
{
public CHILD1()
{
InitializeComponent();
// this.tbx1 is always null
this.tbx1.Focus();
}
}
Part of BASE:
<ContentPresenter Grid.Row="1"
x:Name="cprContent"
Content="" />
Base class code:-
[ContentProperty("Content")]
public partial class cwBase1 : ChildWindow
...
new public object Content
{
get { return cprContent.Content; }
set { cprContent.Content = value; }
}