maohvlean19
maohvlean19

Reputation: 29

How do I create a customized button for use in Visual Basic 2010?

Suppose I have a Microsoft Expression Blend. Is it possible to create a custom control (such as a button) in MSE Blend and then import it to visual basic 2010?

For example, I want to create a custom shape button (different from what is available in the toolbox in VB2010) (like for example a pen-shaped button) in MSE Blend. Can I import it to VB2010 to be used with Windows Forms Projects? If yes, how?

(Added)

If Expression Blend designs cannot be used in windows forms, how then can I create a custom-shaped button in windows forms?

Your response will be very much appreciated.

Upvotes: 1

Views: 4303

Answers (1)

Geoff Appleford
Geoff Appleford

Reputation: 18832

You can use WPF controls created in Expression Blend in a Winforms project.

You use the ElementHost control to host the WPF control. Here's a Channel9 video demonstrating how to do this.

There are some limitations to interop between WPF and Winforms but none will likely stop you creating and using a custom button.

Otherwise you could create the control in Winforms but it will probably not be as easy. You have a few options:

  • Create a UserControl to 'draw' your custom shape. The Region property might help creating a custom shape and you could just use an image of the look you want.

  • Use a custom class (possibly inheriting from Button) where you do all the controls drawing (in the Paint event) and handle all the mouse events yourself. Not an easy task.

Upvotes: 1

Related Questions