2014-01-09 59 views

回答

3

可以很容易地在代码隐藏编程方式创建控件,一个例子发明了名字:

TextBlock colorText = new TextBlock(); 
colortext.Foreground= new SolidColorBrush(Colors.Yellow); 

this.Panel.Children.Add(colortext) 
+0

何处添加此代码? –

+1

您可以在构造函数之后的任何时候在页面的代码中执行它。或者,如果您想在构造函数中执行,则在调用InitializeComponents()后的任何时候。 –

+0

codebehind是与.xaml文件同名的.cs文件 – Juan

相关问题