×

First time here?

You are looking at the most recent posts. You may also want to check out older archives. Please leave a comment, ask a question and consider subscribing to the latest posts via RSS or email. Thank you for visiting!

following up in part 2, we build upon part 1 of our demonstration of using user controls in our silverlight applications.  in part 1, we created our user control in xaml using expression blend and then wired it up in our silverlight 1.0 application using javascript as the code.

in part 2, we take the same xaml, but this time compile it into a managed assembly for consumption in a silverlight 1.1 application.  the result is that we now have a modular approach to reusable components in silverlight and the user control in managed code also affords us familiar implementation style similar to asp.net user control syntax.  rather than only relying on code, we can implement the control directly in the xaml using syntax like <mynamespace:mycontrol />.

the code for part 2 is found here: Screencast.SilverlightControls.zip.  as always, feedback and more suggestions for future screencasts are appreciated!


8/20/2007 6:48 PM | # re: implementing user controls in silverlight 1.1
As a Flex & Flash Developer, I just wanted to say this example is really helpful in understanding (finally!!! w00t!) where Silverlight stands on the control front. It's neat to see how Sliverlight controls imply a code-beind approach (design and layout in XAML, code implementation in CS). The Flex front currently is divided on this issue.

Question about your UpdateLayout function; how does Silverlight invalidation work? Do you have an MSDN link to where I can read more? In Flash Player, we have certain times the screen refreshes, and developers make efforts to only redraw based on this events. Here, it seems to update immediately. I'm assuming either A) this is handled for you, or B) you were being nice for brevity's sake for a simple example.

Thanks again for the example, and thanks for your time.
8/20/2007 9:05 PM | # re: implementing user controls in silverlight 1.1
Hey Jesse, good to see you scoping the .NET/Silverlight front. :-D

You're right on the code-behind approach in the Flex world. I tried it but it just didn't feel right at all. In the .NET world it is just natural and very sweet.

Good post Tim.
8/21/2007 5:57 AM | # re: implementing user controls in silverlight 1.1
Excellent! Now to go one step further...

Can you show how you would add child user controls to the main user control AND how you would declaritively set the child properties, eg, text?
8/23/2007 9:02 PM | # re: implementing user controls in silverlight 1.1
Firstly, Thanks for the screen cast, very imformative. In part 2 you showed us how you can add the control to the app canvas in 2 ways, code and via the xaml file. Will there be the facility to use Blend to 'Drag Drop' a user defined control onto the canvas in the future ? Can you do it now ?
8/23/2007 9:22 PM | # re: implementing user controls in silverlight 1.1
steve: great question -- yes you can. in blend you'd add a reference to the assembly and then the control will show up in the custom controls tab of the control pallette. now, keep in mind the control author would have to have design time support. in my sample a simple box shows up (the button doesn't render well) but at least it adds it to the panel.
8/27/2007 4:13 PM | # re: implementing user controls in silverlight 1.1
Tim, great tutorial. It was to the point and showed me everything to clarify user controls in 1.1. Keep it up, will be checking back for more!
9/22/2007 3:52 PM | # re: implementing user controls in silverlight 1.1
That is awesome...

9/26/2007 6:48 PM | # re: implementing user controls in silverlight 1.1
Do you maybe know away to copy Image clip data that write in xaml ( blend Aug cliping image into a rect )

The data sample is something like that inside the xaml file .

Clip ( M0.5,98.728 C0.5,48.193945 41.465945,7.228 92,7.228 L468,7.228 C518.53405,7.228 559.5,48.193945 559.5,98.728 L559.5,325.728 C559.5,376.26205 518.53405,417.228 468,417.228 L92,417.228 C41.465945,417.228 0.5,376.26205 0.5,325.728 z );


and use this cliping to over ride a clip data of anew image in c# ?

11/16/2007 2:52 PM | # re: implementing user controls in silverlight 1.1
It is nice to see how a good-looking button is implemented in silverlight 1.1. Silverlight is new to me. I see the mouseover and mouseout behavior. I got a question here: given the button defined, how do you specify the onclick event of such a button?
11/26/2007 5:05 PM | # re: implementing user controls in silverlight 1.1
huili: you would add an event listener for the MouseLeftButtonUp event (there is no 'click' but there is mousedown/up)
1/9/2008 5:36 AM | # re: implementing user controls in silverlight 1.1
I have to say that silverlight plugin seems to the future of web design. I'm a flash programmer and this example is really easy to understand. Is there any other examples on this blog or can you post a link?
2/4/2008 12:04 PM | # re: implementing user controls in silverlight 1.1
Thak you the Screecast. i am new to Silverlight. can you tell how can i add keyDown event to a canvas or textblock.
Thanks again
2/4/2008 1:15 PM | # re: implementing user controls in silverlight 1.1
prasa: on any element you can use addEventListener to attach specific events, even KeyDown

 
Please add 5 and 5 and type the answer here:

DISCLAIMER:

The opinions/content expressed on this blog are provided "ASIS" with no warranties and are my own personal opinions/content (unless otherwise noted) and do not represent my employer's view in any way.