none
Form Designer loading problem

    Question

  • Hi,

    I am having a form containing ElementHost control which host WPF user control contains MediaElement control which plays .wmv file on loading.

    when I try to open the form in designer mode I am getting following error-

    Events cannot be set on the object passed to the event binding service because a site associated with the object could not be located.

    please I need urgent help.

    Thanks and regards,
    Prabi
    Thursday, May 28, 2009 6:03 AM

Answers

  • Hi Prabi,

    Once you host a WPF control into winform project, you should add it in the code not designer. Like the sample shown
    http://msdn.microsoft.com/en-us/library/ms745781.aspx

    I have made a test to host a WPF control into winform form(Form1) in the code, then create another form(Form2) to inherited from this one. When I open Form2 in the designer, it cannot be shown and error occur. It reads: Cannot locate resource 'conecontrol.xaml'.

    After consulting for this. I know that WPF control cannot be shown in winform at design time. It only available at run time.

    If I misunderstood you or the step I took different from yours, please feel free to tell me.

    Sincerely,
    Kira Qian


    Please mark the replies as answers if they help and unmark if they don't.
    Monday, June 01, 2009 2:39 AM

All replies

  • Hi Prabi,

    Once you host a WPF control into winform project, you should add it in the code not designer. Like the sample shown
    http://msdn.microsoft.com/en-us/library/ms745781.aspx

    I have made a test to host a WPF control into winform form(Form1) in the code, then create another form(Form2) to inherited from this one. When I open Form2 in the designer, it cannot be shown and error occur. It reads: Cannot locate resource 'conecontrol.xaml'.

    After consulting for this. I know that WPF control cannot be shown in winform at design time. It only available at run time.

    If I misunderstood you or the step I took different from yours, please feel free to tell me.

    Sincerely,
    Kira Qian


    Please mark the replies as answers if they help and unmark if they don't.
    Monday, June 01, 2009 2:39 AM
  • The WPF control could be seen in Designer.

    Just the event handlers should be "deactivated" in the Design mode. (Handles in VB or .Click +=... )

     


    Best regards, Sergiu
    Thursday, January 27, 2011 9:01 PM
  • I have a similar problem. I have two user controls, UserConrol1 and UserControl2. The UserConrol1 has a button MyBtn. I put the UserConrol1 in the UserControl2 and had no problem to open the Designer.
    Then, I added the event handler for the MyBtn in the UserControl2:
    this.UserControl1.MyBtn.Click += new System.EventHandler(MyBtn_Click);
    and the corresponding method:
    void MyBtn_Click(object sender, System.EventArgs e)
    {
        //Some code…
    }

    When I tried to open the Designer, I got the following error:
    To prevent possible data loss before loading the designer, the following errors must be resolved:  
        1 Error  
    Ignore and Continue
     
        Events cannot be set on the object passed to the event binding service because a site associated with the object could not be located.    
     
    Instances of this error (1)
    1.   Hide Call Stack
    at System.ComponentModel.Design.EventBindingService.EventPropertyDescriptor.SetValue(Object component, Object value)
    at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAttachEventStatement(IDesignerSerializationManager manager, CodeAttachEventStatement statement)
    at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)

    If I click on the Ignore and Continue, the Designer is opened and I can see both Controls and MyBtn. It seems that I have no problems at the run time either. I can click on the MyBtn in the UserConrol1 and capture this event in the UserConrol2.

    Any suggestions on how to fix the Designer problem? Thanks.

    Saturday, March 26, 2011 4:54 AM