All,
I've got a generic list defined in a custom user control.
private List<string> m_AnimationNames = new List<string>();
public List<string> AnimationNames
{
get { return this.m_AnimationNames; }
set { this.m_AnimationNames = value; }
}
I reference this list in xaml, and populate it, like so.
<local:AnimatedCharacter.AnimationNames>
<System:String>Walk</System:String>
<System:String>Run</System:String>
<System:String>Talk</System:String>
</local:AnimatedCharacter.AnimationNames>
I then try to reference this list elsewhere in code, after InitializeComponent() is called and the list always returns a size of 0 and contains no elements.
Why is this list empty at runtime? What am I missing that is making this list count 0 when I access it in code?
Full Class:
public partial class AnimatedCharacter : UserControl
{
private List<string> m_AnimationNames = new List<string>();
public AnimatedCharacter()
{
InitializeComponent();
DoSomething();
}
public List<string> AnimationNames
{
get { return this.m_AnimationNames; }
set { this.m_AnimationNames = value; }
}
public void DoSomething(){
Console.WriteLine("Anim: " + AnimationNames.Count);
}
}
}
XAML instance:
<local:AnimatedCharacter x:Name="ac_guy1" Height="315" Width="273" Canvas.Left="-666" Canvas.Top="-99" >
<local:AnimatedCharacter.AnimationNames>
<System:String>Walk</System:String>
<System:String>Run</System:String>
<System:String>Talk</System:String>
</local:AnimatedCharacter.AnimationNames>
</local:AnimatedCharacter>