我在我的应用程序中有一个参数化的构造函数。我想动态地添加控件到我的Silverlight儿童控制页面。但它给了NullReferenceException
。 我找不出为什么它返回null.Can任何帮助我这种情况?异常使用动态添加控件到silverlight childwindow?
public PDFExport(FrameworkElement graphTile1, FrameworkElement graphTile2,FrameworkElement graphTile3)
{
Button btnGraph1 = new Button();
string Name = graphTile1.Name;
btnGraph1.Content = Name;
btnGraph1.Width = Name.Length;
btnGraph1.Height = 25;
btnGraph1.Click += new RoutedEventHandler(btnGraph1_Click);
objStack.Children.Add(btnGraph1);
LayoutRoot.Children.Add(objStack); // Here am getting null Reference Exception
_graphTile1 = graphTile1;
_graphTile2 = graphTile2;
_graphTile3 = graphTile3;
}
谢谢。
栈跟踪将有助于... – Memoizer 2013-02-11 13:46:07