FindName (Dynamic controls)
Posted: 01 Aug 2015, 21:10
Hi, I have this piece of code
and "prueba" is null, the object is there if you get it by DivContent.Children[0] but the problem is affecting me when I try to call a Storyboard with this DivView as target,
sb.Begin(DivContent) gives just an exception saying "The target name 'DivView' cannot be found in the xaml namscope, and I am afraid that both issues are related.
Btw, I call another storyboard with target declared in xaml and it works perfectly so I think it is something with the controls added dynamically.
cheers!
Code: Select all
DivContent.Children.Clear();
var newview = (UserControl) NoesisGUISystem.LoadXaml(xaml);
newview.Name = "DivView";
DivContent.Children.Add(newview);
var prueba = DivContent.FindName("DivView");
Code: Select all
<Window.Resources>
<Storyboard x:Key="StoryboardLoadView">
<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="DivNewView">
<EasingThicknessKeyFrame KeyTime="0:0:0.2" Value="0">
<EasingThicknessKeyFrame.EasingFunction>
<CircleEase EasingMode="EaseOut"/>
</EasingThicknessKeyFrame.EasingFunction>
</EasingThicknessKeyFrame>
</ThicknessAnimationUsingKeyFrames>
</Storyboard>
Btw, I call another storyboard with target declared in xaml and it works perfectly so I think it is something with the controls added dynamically.
cheers!