views:

41

answers:

2

Hi,

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

+1  A: 

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.

ChrisF
A: 

Thanks ChrisF.

I have solved it in this way:

private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {

            if (DesignerProperties.IsInDesignTool)
                return;

            BindCountryList();
        }
burak ozdogan