xaml = new StringBuilder(); xaml.Append(string.Format("<{0} ", item.ControlType)); xaml.Append(nameSpace); xaml.Append(" Grid.Row=\"" + item.X.ToString() + "\" Grid.Column=\"1\" Grid.ColumnSpan=\"3\" "); xaml.Append(string.Format(" Height=\"50\" TextWrapping=\"Wrap\" HorizontalScrollBarVisibility=\"Disabled\" AcceptsReturn =\"true\" x:Name=\"{0}\" {1} {2} />", item.RecordFiled, item.RecordFiled == "CONTENT" ? "IsReadOnly=\"True\"" : "",bindText)); uElement = (UIElement)XamlReader.Load(xaml.ToString());
感激不尽!
后台你为什么不直接使用C#代码编写,还在弄XAML?