请教一个菜鸟问题,XamlReader.Load()函数
我想用XamlReader.Load()函数将一段XAML从c#插入到XAML里去
String xaml = "<Rectangle xmlns=\"http://schemas.microsoft.com/client/2007\" Width=\"20\" Height=\"" + h.ToString() + "\" RadiusX=\"2\" RadiusY=\"2\" Canvas.Left=\"" + (30 * n + 10).ToString() + "\" Canvas.Top=\"" + (300 - h).ToString() + "\" MouseEnter=\"Rectangle_MouseEnter\" MouseLeave=\"MyRec_MouseLeave\"/>";
Rectangle rect = (Rectangle)XamlReader.Load(xaml);
this.LayoutRoot.Children.Add(rect);