为什么我会收到此错误:“域操作无法在设计时启动?”

发布于 2024-09-26 22:36:16 字数 236 浏览 0 评论 0原文

我创建了一个银光用户控件,我想在新视图 (MyTest.xaml) 中测试它。 我可以在工具箱中看到我的用户控件。但是,当我将其拖放到设计区域时,出现此错误:

无法创建 ctlMyControl 的实例。 域操作无法在设计时启动。

基本上,它是一个带有下拉菜单的控件,调用 RIA 服务来填充其 ItemsSource。

知道为什么我会收到此错误吗?

谢谢

I have created a silver light user control and I want to test it in a new View (MyTest.xaml).
I can see my user control in the toolbox. But when I drag and drop it to the design area in I get this error:

Cannot create an instance of ctlMyControl.
Domain operations cannot be started at design time.

Basically, it is a control with a drop down which calls a RIA service to populate its ItemsSource.

Any idea why I may be getting this error?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

野生奥特曼 2024-10-03 22:36:16

您的控件正在尝试调用 RIA 服务,这在设计时是不允许的。

您需要将一些代码放入您的控件中以防止在设计时发生这种情况。

有一个属性 DesignMode 您可以用来检查您的控件是否应该实际工作或只是显示占位符。

Your control is trying to make the call to the RIA service which isn't allowed at design time.

You need to put some code into your control to prevent this happening at design time.

There's a property DesignMode you can use to check on to see whether your control should be actually working or just displaying a placeholder.

亽野灬性zι浪 2024-10-03 22:36:16

谢谢克里斯F。

我是这样解决的:

private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {

            if (DesignerProperties.IsInDesignTool)
                return;

            BindCountryList();
        }

Thanks ChrisF.

I have solved it in this way:

private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {

            if (DesignerProperties.IsInDesignTool)
                return;

            BindCountryList();
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文