tags:

views:

89

answers:

2

Hi,

Time ago I created an application which has some buttons in the form. Now the customer wants me to modify the existing application so he can add custom buttons.

Now there are some existing buttons (ex. button1, button2, button3...) and I have to create a button "Add new..." so the user can add a new button below the existing buttons in the form.

So far I have been creating user interfaces by simply placing controls to the form in Visual Studio so I would be thankful if anyone suggested any way to implement the described functionality.

The existing application is Windows Forms Application (C#, .NET framework v3.5) and the client is using Windows XP. It might be easier to create a WPF application but I am not sure if it is possible to run it on Windows XP...

Thank you!

+10  A: 

If c# you can just create a new dynamic button using

Button btn1 = new Button();
this.Controls.Add(btn1);

You can add more properties to btn1

What are the buttons supposed to do?

Shoban
A: 

Rather than a potential rewrite of the entire application in WPF you can do a partial migration by embedding WPF controls in a WinForm app.

You add an ElementsHost to the toolbox this resides in the System.Windows.Forms.Integration namespace and is part of .Net 3.0. This can then be dragged on to the form or added in code. The control has a child property which in turn can be a WPF UIElement.

WPF is far more powerful in the area of styling and customising the look of a control than custom drawn controls done the old way in Winforms however there is a learning curve. Is this your requirement?

WPF works fine with XP.

Just a few thoughts.

Andrew