如何在 Expression Blend 中添加自定义控件?
我有一个使用Expression Blend
创建的表单。早些时候,当我在 Visual Studio 中创建一个控件时,我可以使用 Controls.Add()
添加自定义控件。一个例子如下。
Using SriClocks;
//////////////////////Blah blah
public Form1()
{
InitializeComponent();
SriClocks.DigitalClockCtrl clk = new DigitalClockCtrl();
clk.Size = new Size(500, 150);
clk.Show();
this.Controls.Add(clk);
clk.SetDigitalColor = DigitalColor.GreenColor;
}
当我使用表达式混合创建表单时,无法使用上述方法向表单添加控件。经过
this.Controls.Add(**)Can someone please let me know how to achieve this task! Thanks a lot.
I have a Form created using Expression Blend
. Earlier when I created one in Visual Studio, I could add a custom control using Controls.Add()
. An example would be as follows.
Using SriClocks;
//////////////////////Blah blah
public Form1()
{
InitializeComponent();
SriClocks.DigitalClockCtrl clk = new DigitalClockCtrl();
clk.Size = new Size(500, 150);
clk.Show();
this.Controls.Add(clk);
clk.SetDigitalColor = DigitalColor.GreenColor;
}
When I create the form using expression blend, I can't use the above method to add a control to the form. by
this.Controls.Add(**)
Can someone please let me know how to achieve this task!
Thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的第一个代码示例看起来像 Windows.Forms 应用程序,但 Expression Blend 创建了 WPF 应用程序。因此,没有
this.Controls
-Enumeration。您应该将控件添加到 Grid(或您使用的任何其他容器),例如Class1.xaml
Class1.xaml.cs
Your first code example looks like a Windows.Forms application, but Expression Blend creates WPF applications. Therefore there is no
this.Controls
-Enumeration. You should add the Control to theGrid
(or whatever else container you used), likeClass1.xaml
Class1.xaml.cs