Dec 07

The purpose of this post is to show you how to declare and use a specific user control in Silverlight. To do this I'll use a simple example of a Wizard page containing user control representing steps.

Here is the corresponding class diagram:

clip_image002

In our example each wizard step is a “UserControl” type “WizardControl” that is to say; it contains the method “Next” and “Previous” as defined in the interface “IWizardControl”.

How do I create it step by step?

Step 1: Create the base class

public class WizardControl : UserControl, IWizardControl
{
    public virtual void Next() { }
    public virtual void Previous() { }
}

Step 2: Initialization in XAML

<src:WizardControl x:Class="UserControlInheritance.WizardStep1"
    xmlns:src="clr-namespace:UserControlInheritance.Controls"
</src:WizardControl>

Step 3: in the code behind, we inherit WizardControl

public partial class WizardStep1 : UserControlInheritance.Controls.WizardControl
{
    public WizardStep1()
    {
        InitializeComponent();
    }

    public override void Next()
    {
        base.Next();
        MessageBox.Show(String.Format("Hello {0}", NameTextBox.Text));
    }

    public override void Previous()
    {
        base.Previous();
    }
}

Use of the user controls

And finally, as a result, we can create a wizard with a list of the different steps. Like this:

wizard = new List<WizardControl>()
{
	new WizardStep1(), 
	new WizardStep2()
};

WizardControl currentControl = contentControl.Content as WizardControl;
contentControl.Content = controls[currentIndex];

And here is the "visual" result:

clip_image004

Full source code here:

Tags:

Comments

Wendy Drivng Schools

Posted on Sunday, 4 July 2010 03:48

Nice post! Love to see more coming from you, I've read your stuff before.

luggage scales

Posted on Monday, 5 July 2010 18:45

To do this I'll use a simple example of a Wizard page containing user control representing steps.

CAROL

Posted on Monday, 19 July 2010 20:06

anyone has a demo version?

ronald napole

Posted on Monday, 19 July 2010 20:08

i'm going to send you tomorrow...
good luck Smile

Blog Literature

Posted on Thursday, 22 July 2010 16:57

I also want to download its demo version. Can you give me the url where i can download it?

idolreplicas

Posted on Saturday, 24 July 2010 00:01



I was very glad to discover this site on google.I wished to say thank you to you with regard to this superb article!! I definitelyliked every little bit of it and I've you bookmarked to check out new stuff you post.

Alfred Harbour

Posted on Sunday, 8 August 2010 09:56

Marvelous! Not clear for me, how often you�d updating your site?

Rodolfo Browers

Posted on Sunday, 8 August 2010 13:27

computer repair saint paul

Posted on Tuesday, 10 August 2010 05:25

Great information!  I just love your blog.  I can't wait to hear more from you.

Reid Browy

Posted on Tuesday, 10 August 2010 08:14

thanx silverlight

Annie Bondurant

Posted on Monday, 16 August 2010 17:43

lol, thx!

miami flat fee mls listing

Posted on Wednesday, 18 August 2010 16:28

Hey,

I wanted to say that I have been reading for a few months on and off and I would like to sign up for the daily feed. I am not to computer smart so I'll give it a try but I might need some help. This is a good find and I would hate to lose contact, and maybe never discover it again.

Anyway, thanks again and I look forward to posting again in the future!

realtouch

Posted on Monday, 30 August 2010 03:41

I take great delight in your blog, Its very good to observe not every person is just posting a mess of waste now a days!

realtouch

Posted on Monday, 30 August 2010 05:59

I care for your blog, Its good to find not all people is just posting a bunch of rubbish these days!

clarinet overhaul

Posted on Tuesday, 31 August 2010 12:47

Great tutorial. You make it so easy.

wedding dresses cheap

Posted on Saturday, 4 September 2010 04:23

Location fee

hulu converter

Posted on Sunday, 5 September 2010 01:17

keep up to date with incoming post.

jewellers Romford

Posted on Thursday, 9 September 2010 13:23

Come again? added possibly will occur assumed?

Wedding Photographers Romford

Posted on Thursday, 9 September 2010 14:29

When you  get time can you mark supplementary?

Anthony Emlin

Posted on Wednesday, 22 September 2010 12:31

I'm sure you should pick up a bit the look and usability of your blog.

jearte

Posted on Saturday, 25 September 2010 13:20

if you do bad you pay, I have  big house in Virgo they where wheat as vagggine on a pole

Pardoseli Epoxidice

Posted on Tuesday, 28 September 2010 08:42

This is an interesting approach

outlook pst repair

Posted on Tuesday, 28 September 2010 14:56

Thanks for the post, it was nice. I read your other post as well, all were good. I really appreciate the author. You are bookmarked.

Calgary Managed server

Posted on Tuesday, 28 September 2010 14:59

Thank you so much for this amazing story. I loved to read that post. It was very interesting and informative. You are bookmarked....

Blanche Heistand

Posted on Thursday, 30 September 2010 22:54

I was extremely delighted to find this site.I wanted to say thanks to you with regard to this excellent read!! I certainly enjoyed every little bit of it and I've you bookmarked to look at new things you publish.

Fannie Golish

Posted on Friday, 1 October 2010 21:26

I am very pleased to locate this website.I wanted to thank you with regard to this great read!! I definitely enjoyed every little bit of it and I have you bookmarked to check out new stuff you post.

spiritual healing

Posted on Saturday, 2 October 2010 07:43

Spiritual energy healing and spiritual healing. Restore proper energy flow. Get connected. FEEL GREAT! Be empowered. LIVE a more ENJOYABLE LIFE!

write obama

Posted on Monday, 4 October 2010 05:25

Writing a "PurpleLetter" is the easiest and most effective way to exercise your right to free speech. We will amplify your voice like you won't believe.

SQUIRTING ORGASM MASTERY

Posted on Thursday, 7 October 2010 05:37

I can ask you?

It's Just Lunch

Posted on Tuesday, 12 October 2010 06:34

What dating network can I join that can get me a quick lay?

new laptop battery

Posted on Wednesday, 13 October 2010 20:04

Personally I know a guy is gay when we meet and i feel the need to check my fly.

how to win the lottery guaraneed

Posted on Friday, 15 October 2010 17:02

There's the joke about the guy who's been praying to God for months to win the lottery without the need of a result. Ultimately he's had sufficient and asks God why he hasn't won yet. God replies: my son, inform you what I'll meet you halfway: go and buy a ticket first.

Clara Mckethan

Posted on Saturday, 16 October 2010 01:44


Me and my wife <STRONG>love</STRONG> your blog but our son hates it, bye

mycloudwork

Posted on Saturday, 16 October 2010 13:57

Great Information, thanks for the great Post. I will come back soon .

microjob

Posted on Saturday, 16 October 2010 14:55

Great Post, thanks for your great Post. I will come back later  .

mycloudwork

Posted on Saturday, 16 October 2010 14:58

Awesome Post, thanks for the useful Post. I will come back later !

Hidden object game

Posted on Saturday, 16 October 2010 23:51

A great post. Thanks for sharing it with me!

how to make your breasts bigger

Posted on Monday, 18 October 2010 18:50

All new to me; I wasn't aware of the many ramifications and depth to this story until I searched here through Bing! Good job.

notebook

Posted on Tuesday, 19 October 2010 12:53

Great Post, thanks for your great Post. I will come back later  .

male fertility test

Posted on Tuesday, 19 October 2010 17:17

All new to me; I wasn't aware of the many ramifications and depth to the case until I searched here through Bing! Great job.

Mahjong games online

Posted on Wednesday, 20 October 2010 00:21

I mean, superb portal. I visit here evaryday.

cute handbag

Posted on Wednesday, 20 October 2010 06:19

Keep working ,great job!:[:[

favourite lounge

Posted on Wednesday, 20 October 2010 12:54

i love songs by barbie's cradle/ barbie almalbis. like torpe, someday, just a smile and all i need. the singer kitchie nadal is good too. these aren't really classic songs, but they're my favourite. Smile i guess i would categorize them under alternative pop? acoustic..

Mahjong

Posted on Wednesday, 20 October 2010 15:26

I think helpful article. I found it on google.

Add comment




  Country flag

biuquote
Loading