private void RecalculateVisibility(object oldValue, object newValue)
{
if(AutoChild)
{
// when datacontext change is fired but its not loaded, it's quite possible that some Common.Routes are not working yet
if (newValue == null/* || !IsLoaded*/)
Child = null;
else
{
EntitySettings es = Navigator.Manager.EntitySettings.TryGetC(newValue.GetType());
if (es == null)
Child = new TextBox
{
Text = "No EntitySettings for {0}".FormatWith(newValue.GetType()),
Foreground = Brushes.Red,
FontWeight = FontWeights.Bold
};
else
Child = es.CreateView((ModifiableEntity)newValue, Common.GetPropertyRoute(this));
}
}
if (Child != null)
{
if (newValue == null)
Child.Visibility = Visibility.Hidden;
else
Child.Visibility = Visibility.Visible;
if (oldValue != null && newValue != null)
Child.BeginAnimation(UIElement.OpacityProperty, animation);
}
}
}