开发者

Why do I get this error : "Domain operations cannot be started at design time?"

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


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.


Thanks ChrisF.

I have solved it in this way:

private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {

            if (DesignerProperties.IsInDesignTool)
                return;

            BindCountryList();
        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜