PDA

View Full Version : Dinamic Components on a Form



al303576
August 20th, 2009, 07:41 PM
Hi all, I'm try to do an application where the buttons, textbox, combo box,etc can be add on my Form from a xml configuration file, is it possible on Expression blen application with c#.

I did this on a pure C# application but i want update my user gui with a nice interface....

Sorry for my grammar.

also i'm new with this world of PC visual applications i'm a firmware programmer.

Thanks for you help.

Martin.

kirupa
August 21st, 2009, 06:28 AM
Al, are you saying that you have an XML that will help your determine where to place buttons and other such things?

One thing you can do is drop a button in Blend, edit it and create a style, and once you have your style created, programmatically assign it to the elements you are adding via C#. An example of this can be seen here: http://blog.kirupa.com/?p=56

Cheers!
Kirupa :)

al303576
August 21st, 2009, 02:02 PM
thaks i'm going to check that link, afeter i will post here my results.

Martin

al303576
August 24th, 2009, 07:11 PM
Well i wrote a simple code, but this not work. i'm doing some wrong?, the style don't change on that button.

My form only has two butons one button is from blend this button have the style name "SimpleButton", so on the second button (i drew this button on c# express edition)on the event click for this button i add the next code:

privatevoid button1_Click(object sender, RoutedEventArgs e)
{
Style lstyle = Window.Resources["SimpleButton"] asStyle;
((Button)sender).Style = lstyle;
}

But, the style for this button don't change after click event. :)

kirupa
August 25th, 2009, 01:34 AM
That is really strange. I have attached a simple project where I emulate your application based on your description.

Are you able to see where you and I are differing?

Cheers!
Kirupa :)

al303576
August 25th, 2009, 11:59 AM
Offcourse, man i will check what is diferent, i ran your application and works great! so some is wrong or missing on my application, Thanks for the help, i post here my status.

Martin.

al303576
August 25th, 2009, 12:55 PM
Ok, man now it's working on my application, simply began a new project and works.... here is my simple demo. Thanks so much went the application is done i will post the result.

:hugegrin:
Martin