All,
I have a simple class.
public class Container : UserControl
{
public bool IsClickable { get; set; }
}
I have a class that extends this class.
public class ScrollingContainer : Container
{
public void Draw()
{
}
public void Update()
{
}
}
I have my own class, which then extends the ScrollingContainer.
public partial class MaskContainer : ScrollingContainer
{
public MaskContainer()
{
InitializeComponent();
}
}
Xaml
<local:ScrollingContainer x:Class="Test.Types.MaskContainer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GameObjects;assembly=GameObjects"
mc:Ignorable="d"
>
</local:ScrollingContainer>
In my mainpage.xaml, I have the following.
<types:MaskContainer x:Name="maskContainer" Canvas.ZIndex="1" Width="Auto" Height="Auto">
<Canvas x:Name="maskCanvas">
<Button x:Name="button1" Content="test button"/>
</Canvas>
</types:MaskContainer>
Why are both maskCanvas and button1 null at runtime? maskContainer is not zero.
Inheritance should be straightforward. The container inherits user control. A scrollable container inherits a container. Mask Container inherits a scrollable container. Why am I losing the functionality of the original base class at this level? Is it wrong to add the element (button1) to the mask container inside main.xaml?
- , , /, .
.