<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
    <channel>
        <title>Imran Shaik</title>
        <link>http://geekswithblogs.net/Silverlight2/Default.aspx</link>
        <description>Silverlight 2.0 Quintessential Rambling </description>
        <language>en-GB</language>
        <copyright>Imran Shaik</copyright>
        <managingEditor>iashaik@gmail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <image><link>http://creativecommons.org/licenses/by-nc-sa/2.0/</link><url>http://creativecommons.org/images/public/somerights20.gif</url><title>Some Rights Reserved</title></image>
        <geo:lat>0</geo:lat><geo:long>0</geo:long><creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/2.0/</creativeCommons:license><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/imranshaik" type="application/rss+xml" /><feedburner:emailServiceId>imranshaik</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2Fimranshaik" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fimranshaik" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2Fimranshaik" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/imranshaik" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fimranshaik" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fimranshaik" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fimranshaik" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare href="http://www.plusmo.com/add?url=http%3A%2F%2Ffeeds.feedburner.com%2Fimranshaik" src="http://plusmo.com/res/graphics/fbplusmo.gif">Subscribe with Plusmo</feedburner:feedFlare><feedburner:feedFlare href="http://my.feedlounge.com/external/subscribe?url=http%3A%2F%2Ffeeds.feedburner.com%2Fimranshaik" src="http://static.feedlounge.com/buttons/subscribe_0.gif">Subscribe with FeedLounge</feedburner:feedFlare><feedburner:feedFlare href="http://www.thefreedictionary.com/_/hp/AddRSS.aspx?http%3A%2F%2Ffeeds.feedburner.com%2Fimranshaik" src="http://img.tfd.com/hp/addToTheFreeDictionary.gif">Subscribe with The Free Dictionary</feedburner:feedFlare><feedburner:feedFlare href="http://www.bitty.com/manual/?contenttype=rssfeed&amp;contentvalue=http%3A%2F%2Ffeeds.feedburner.com%2Fimranshaik" src="http://www.bitty.com/img/bittychicklet_91x17.gif">Subscribe with Bitty Browser</feedburner:feedFlare><feedburner:feedFlare href="http://www.live.com/?add=http%3A%2F%2Ffeeds.feedburner.com%2Fimranshaik" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><feedburner:feedFlare href="http://mix.excite.eu/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fimranshaik" src="http://image.excite.co.uk/mix/addtomix.gif">Subscribe with Excite MIX</feedburner:feedFlare><feedburner:feedFlare href="http://www.yourminis.com/subscribe.aspx?u=http%3A%2F%2Ffeeds.feedburner.com%2Fimranshaik" src="http://www.yourminis.com/images/addtoyourminisbadge.gif">Subscribe with Yourminis.com</feedburner:feedFlare><feedburner:feedFlare href="http://download.attensa.com/app/get_attensa.html?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fimranshaik" src="http://www.attensa.com/blogs/attensa/WindowsLiveWriter/BadgeredintoBadges_10C02/attensa_feed_button5.gif">Subscribe with Attensa for Outlook</feedburner:feedFlare><feedburner:feedFlare href="http://www.webwag.com/wwgthis.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fimranshaik" src="http://www.webwag.com/images/wwgthis.gif">Subscribe with Webwag</feedburner:feedFlare><feedburner:feedFlare href="http://hub.netomat.net/account/account.autoSubscribe.jspa?urls=http%3A%2F%2Ffeeds.feedburner.com%2Fimranshaik" src="http://www.netomat.net/blogger/images/icon_netomat_feedbutton.gif">Subscribe with netomat Hub</feedburner:feedFlare><feedburner:feedFlare href="http://www.dailyrotation.com/index.php?feed=http%3A%2F%2Ffeeds.feedburner.com%2Fimranshaik" src="http://www.dailyrotation.com/rss-dr2.gif">Subscribe with Daily Rotation</feedburner:feedFlare><feedburner:feedFlare href="http://www.podcastready.com/oneclick_bookmark.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fimranshaik" src="http://www.podcastready.com/images/podcastready_button.gif">Subscribe with Podcast Ready</feedburner:feedFlare><feedburner:feedFlare href="http://www.flurry.com/pushRssFeed.do?r=fb&amp;url=http%3A%2F%2Ffeeds.feedburner.com%2Fimranshaik" src="http://www.flurry.com/images/flurry_rss_logo2.gif">Subscribe with Flurry</feedburner:feedFlare><feedburner:feedFlare href="https://intouch.particls.com/download/?mode=2&amp;feed=http%3A%2F%2Ffeeds.feedburner.com%2Fimranshaik" src="https://intouch.particls.com/resources/buttons/it-button2.gif">Subscribe with Particls</feedburner:feedFlare><feedburner:feedFlare href="http://www.addtoany.com/?linkname=Imran%20Shaik&amp;linkurl=http%3A%2F%2Ffeeds.feedburner.com%2Fimranshaik&amp;type=feed" src="http://www.addtoany.com/addfr-b.gif">Add to Any Feed Reader</feedburner:feedFlare><feedburner:feedFlare href="http://www.fwicki.com/users/default.aspx?addfeed=http%3A%2F%2Ffeeds.feedburner.com%2Fimranshaik" src="http://www.fwicki.com/images/ui/fwicki_clicklet.png">Subscribe with fwicki</feedburner:feedFlare><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
            <title>Understanding: Dependency Properties in Silverlight</title>
            <category>Silverlight</category>
            <link>http://feedproxy.google.com/~r/imranshaik/~3/5Z6V9GeV4BY/understanding-dependency-properties-in-silverlight.aspx</link>
            <description>&lt;p&gt;This  is  written to explain Dependency Properties in general as they are available in .NET Framework 3.0 but specifically targeting Silverlight 2.0, in most places effort has been placed to  explain the differences in Dependency Properties in WPF and Silverlight (With Silverlight perspective). But all examples are for Silverlight. &lt;/p&gt;
&lt;h4&gt;What is Dependency Property?&lt;/h4&gt;
&lt;p&gt;Dependency properties are new addition to .NET Framework 3.0, Dependency properties are completely new implementation of properties, all programmers are familiar with properties but Dependency properties have a significant amount of added value. They use a sophisticated storage and support higher level features such as property value change notification, property validation, property coercion, property metadata and default property value inheritance. Dependency properties can hold an optional default value, and can propagate the default value down the element tree. &lt;/p&gt;
&lt;p&gt;Simply put, a Dependency Property is like any other property but can hold a default value, with built in mechanism for property value validation and automatic notification for changes in property value ( for anyone listening to property value - especially UI)  and any binding in Silverlight is to binded to a Dependency Property. &lt;/p&gt;
&lt;h4&gt;Dependency Properties Features: &lt;/h4&gt;
&lt;ul&gt;
    &lt;li&gt;Root class must be inherited from UIElement or DependencyObject (Eg., Controls, User Controls, Windows (WPF), or any class derived from UIElement (Button, List, Slider etc.)) &lt;/li&gt;
    &lt;li&gt;Dependency Properties have to be registered using DependencyProperty.Register method. &lt;/li&gt;
    &lt;li&gt;Since DependencyProperty.Register is a static (C#) / Shared (VB.NET) method, all dependency properties should also be static/Shared fields, also the property changed callback methods should be static/Shared methods. &lt;/li&gt;
    &lt;li&gt;Any property must be a dependency property if the property is being binded to. &lt;/li&gt;
    &lt;li&gt;By convention, all Dependency Property fields should include the word “Property” at the end of the property name (e.g., for property Value, the Dependency Property name should be ValueProperty). &lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Defining and Registering a Dependency Property: &lt;/h4&gt;
&lt;p&gt;While working with .NET 3.0/.NET 3.5 Framework (WPF, Silverlight) you’ll spend more time using Dependency Properties instead of defining them, most of the time you won’t even realise you are using a Dependency Property, but you should be able to create and register Dependency Properties as they are key in designing custom controls, or if you wish to add additional properties for binding, animation or other UI features that would otherwise be not supported. &lt;/p&gt;
&lt;p&gt;The syntax of defining a Dependency Property is different from traditional Properties, however features mentioned above should always be remembered while defining Dependency Properties. &lt;/p&gt;
&lt;p&gt;Defining Syntax: &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;VB.NET&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;Public Class &lt;/span&gt;FrameworkElement
    &lt;span style="COLOR: blue"&gt;Inherits &lt;/span&gt;UIElement

    . . . 
    &lt;span style="COLOR: blue"&gt;Public Shared ReadOnly &lt;/span&gt;ValueProperty &lt;span style="COLOR: blue"&gt;As &lt;/span&gt;DependencyProperty

    . . . 

&lt;span style="COLOR: blue"&gt;End Class&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt; &lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;public class &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;FrameworkElement &lt;/span&gt;: &lt;span style="COLOR: #2b91af"&gt;UIElement
&lt;/span&gt;{

    . . . 

    &lt;span style="COLOR: blue"&gt;public static readonly &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;DependencyProperty &lt;/span&gt;ValueProperty; 

    . . . 

}&lt;/pre&gt;
&lt;p&gt;Defining a dependency property is only the first step, in order of the Dependency Property to be used, it should be registered, the registration process also initialises a DependencyObject.  &lt;/p&gt;
&lt;p&gt;The Framework ensures that the DependencyProperty objects is not instantised directly since DependencyObjects don’t have public constructors. Hence DependencyObject can only be initialised by using static/Shared DependencyProperty.Register method. &lt;/p&gt;
&lt;p&gt;The keyword “Readonly” in the above definition means that the property can only be registered in the static (C#) / Shared (VB.NET) constructor of the class and once registered in can’t be changed(registration) or re-register hence it is readonly, and it doesn’t make the Dependency Property readonly, only that it can’t be reregistered. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Registering Dependency Property &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;To register the dependency property defined above we have to put them in static/Shared Constructor since they are declared as readonly.  &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;VB.NET &lt;/strong&gt;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;Public Class &lt;/span&gt;FrameworkElement
    &lt;span style="COLOR: blue"&gt;Inherits &lt;/span&gt;UIElement


    &lt;span style="COLOR: blue"&gt;Public Shared ReadOnly &lt;/span&gt;ValueProperty &lt;span style="COLOR: blue"&gt;As &lt;/span&gt;DependencyProperty

    &lt;span style="COLOR: blue"&gt;Shared Sub New&lt;/span&gt;()
        ValueProperty = DependencyProperty.Register(&lt;span style="COLOR: #a31515"&gt;"Value"&lt;/span&gt;, &lt;span style="COLOR: blue"&gt;GetType&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;Integer&lt;/span&gt;), &lt;span style="COLOR: blue"&gt;GetType&lt;/span&gt;(FrameworkElement), &lt;span style="COLOR: blue"&gt;Nothing&lt;/span&gt;)
    &lt;span style="COLOR: blue"&gt;End Sub


End Class&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;C# &lt;/strong&gt;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;public class &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;FrameworkElement &lt;/span&gt;: &lt;span style="COLOR: #2b91af"&gt;UIElement
&lt;/span&gt;{

    &lt;span style="COLOR: blue"&gt;public static readonly &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;DependencyProperty &lt;/span&gt;ValueProperty;

    &lt;span style="COLOR: blue"&gt;static &lt;/span&gt;FrameworkElement()
    {
        
        ValueProperty = &lt;span style="COLOR: #2b91af"&gt;DependencyProperty&lt;/span&gt;.Register(&lt;span style="COLOR: #a31515"&gt;"Value"&lt;/span&gt;, &lt;span style="COLOR: blue"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;), &lt;span style="COLOR: blue"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;FrameworkElement&lt;/span&gt;), &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;);&lt;span style="COLOR: green"&gt;
    &lt;/span&gt;}

}&lt;/pre&gt;
&lt;p&gt;In Silverlight 2.0, static/Shared method of DependencyProperty.Register  takes 4 parameters, there are no overloads available as they are in WPF.  &lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;Name of the property to be registered &lt;/li&gt;
    &lt;li&gt;Data type of the Dependency Property being registered &lt;/li&gt;
    &lt;li&gt;Owner (Data type of parent) of the Dependency Property being registered (typically the root class).  &lt;/li&gt;
    &lt;li&gt;Metadata of the Dependency Property (Optional by specifying null (C#)/Nothing (VB.NET)) &lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; You can also define and register DependencyProperty at the same time but you can optionally exclude “readonly” from the DependencyProperty definition. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;C#:&lt;/strong&gt; public static DependencyProperty ValueProperty = DependencyProperty.Register(…);&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;VB.NET:&lt;/strong&gt; Public Shared ValueProperty As DependencyProperty = DependencyProperty.Register(…)&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;&lt;strong&gt;Reading and Writing Dependency Property values &lt;/strong&gt;&lt;/h4&gt;
&lt;p&gt;Once a Dependency Property is defined and registered, you can’t use these properties as traditional .NET properties, Dependency Properties values should be set/get in a different way. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Getting Dependency Property Value&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The beauty of Dependency Properties is that it can be used or called by any class or object where the Dependency Property parent class is available (specifically the default value) , even if you haven’t locally defined the parent class, for example you can get the default value down the tree of the parent or child of the class without first initialising the class. The only condition is that the parent class assembly should be made available. &lt;/p&gt;
&lt;p&gt;The method to be used to get the value of a Dependency Property is GetValue()&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;VB.NET &lt;/strong&gt; &lt;/p&gt;
&lt;pre class="code"&gt;GetValue(FrameworkElement.ValueProperty)&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;&lt;strong&gt;C# &lt;/strong&gt;&lt;/p&gt;
&lt;pre class="code"&gt;GetValue(&lt;span style="COLOR: #2b91af"&gt;FrameworkElement&lt;/span&gt;.ValueProperty); &lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;&lt;strong&gt;Setting Dependency Property Value&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Similar to getting the property, setting the property value of a Dependency Property should be done by a method SetValue(), the property name should be with reference to the owner class along with the DependencyProperty. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;VB.NET &lt;/strong&gt;&lt;/p&gt;
&lt;pre class="code"&gt;SetValue(FrameworkElement.ValueProperty, 4)&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;&lt;strong&gt;C# &lt;/strong&gt;&lt;/p&gt;
&lt;pre class="code"&gt;SetValue(&lt;span style="COLOR: #2b91af"&gt;FrameworkElement&lt;/span&gt;.ValueProperty, 4);&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h4&gt;Property Wrapper&lt;/h4&gt;
&lt;p&gt;There is a limitation on the methods GetValue and SetValue, in order for a DependencyProperty to be set/get a value the class setting/getting should also be inherited from DependencyObject/UIElement, since GetValue and SetValue methods are inherited from DependencyObject class. In order to overcome this and the simplify the use of Dependency Properties and to make easy and transparent transition (in using) between Dependency Property and Attached Property, Property wrappers are used and are defined within the same class as the definition of Dependency Property.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;VB.NET&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;Public Property &lt;/span&gt;Value() &lt;span style="COLOR: blue"&gt;As Integer
    Get
        Return &lt;/span&gt;GetValue(ValueProperty)
    &lt;span style="COLOR: blue"&gt;End Get
    Set&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;ByVal &lt;/span&gt;value &lt;span style="COLOR: blue"&gt;As Integer&lt;/span&gt;)
        SetValue(ValueProperty, value)
    &lt;span style="COLOR: blue"&gt;End Set
End Property&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;public int &lt;/span&gt;Value
{
    &lt;span style="COLOR: blue"&gt;get
    &lt;/span&gt;{
        &lt;span style="COLOR: blue"&gt;return &lt;/span&gt;(&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;) GetValue(ValueProperty);
    }
    &lt;span style="COLOR: blue"&gt;set
    &lt;/span&gt;{
        SetValue(ValueProperty, &lt;span style="COLOR: blue"&gt;value&lt;/span&gt;);
    }
}&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;By using property wrappers now the transition between Dependency Properties and normal Properties is transparent, we can carry on using Dependency Properties like we use Properties, in property wrappers any other code like raising an event or validating values should not be included, the wrapper automatically ignores any other code within the wrapper and only looks for SetValue/GetValue methods. &lt;/p&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;h4&gt;Dependency Property Metadata  &lt;/h4&gt;
&lt;p&gt;In WPF Dependency Property Metadata is very complex and there are many overloads available but in Silverlight 2.0, Dependency Property Metadata only support two objects, with a maximum of three overloads &lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;Default Value &lt;/li&gt;
    &lt;li&gt;Property Changed Callback &lt;/li&gt;
    &lt;li&gt;Default Value, Property Changed Callback &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;VB.NET&lt;/strong&gt; &lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;Public Class &lt;/span&gt;FrameworkElement
    &lt;span style="COLOR: blue"&gt;Inherits &lt;/span&gt;UIElement

    &lt;span style="COLOR: blue"&gt;Public Shared ReadOnly &lt;/span&gt;ValueProperty &lt;span style="COLOR: blue"&gt;As &lt;/span&gt;DependencyProperty

    &lt;span style="COLOR: blue"&gt;Shared Sub New&lt;/span&gt;()

        ValueProperty = DependencyProperty.Register(&lt;span style="COLOR: #a31515"&gt;"Value"&lt;/span&gt;, &lt;span style="COLOR: blue"&gt;GetType&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;Integer&lt;/span&gt;), &lt;span style="COLOR: blue"&gt;GetType&lt;/span&gt;(FrameworkElement), _
                  &lt;span style="COLOR: blue"&gt;New &lt;/span&gt;PropertyMetadata(0, &lt;span style="COLOR: blue"&gt;New &lt;/span&gt;PropertyChangedCallback(&lt;span style="COLOR: blue"&gt;AddressOf &lt;/span&gt;FrameworkElementValueChanged)))

    &lt;span style="COLOR: blue"&gt;End Sub

    Shared Sub &lt;/span&gt;FrameworkElementValueChanged(&lt;span style="COLOR: blue"&gt;ByVal &lt;/span&gt;sender &lt;span style="COLOR: blue"&gt;As &lt;/span&gt;DependencyObject, &lt;span style="COLOR: blue"&gt;ByVal &lt;/span&gt;e &lt;span style="COLOR: blue"&gt;As &lt;/span&gt;DependencyPropertyChangedEventArgs)

    &lt;span style="COLOR: blue"&gt;End Sub
End Class&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt; &lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;public class &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;FrameworkElement &lt;/span&gt;: &lt;span style="COLOR: #2b91af"&gt;UIElement
&lt;/span&gt;{

    &lt;span style="COLOR: blue"&gt;public static readonly &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;DependencyProperty &lt;/span&gt;ValueProperty;

    &lt;span style="COLOR: blue"&gt;static &lt;/span&gt;FrameworkElement()
    {
        
        ValueProperty = &lt;span style="COLOR: #2b91af"&gt;DependencyProperty&lt;/span&gt;.Register(&lt;span style="COLOR: #a31515"&gt;"Value"&lt;/span&gt;, &lt;span style="COLOR: blue"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;), &lt;span style="COLOR: blue"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;FrameworkElement&lt;/span&gt;), 
            &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;PropertyMetadata&lt;/span&gt;(0, &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;PropertyChangedCallback&lt;/span&gt;(FrameworkElementValueChanged)));
    }

    &lt;span style="COLOR: blue"&gt;static void &lt;/span&gt;FrameworkElementValueChanged(&lt;span style="COLOR: #2b91af"&gt;DependencyObject &lt;/span&gt;sender, &lt;span style="COLOR: #2b91af"&gt;DependencyPropertyChangedEventArgs &lt;/span&gt;e)
    {

    }

} &lt;/pre&gt;
&lt;p&gt;In above mentioned examples, the ValueProperty will hold a default value of 0  and every time the value is changed (except for setting the default value), a property changed callback method is invoked (in this example, FrameworkElementValueChanged), the property changed callback should also be a static/Shared method/function, which take two parameters – DependencyObject and DependencyPropertyChangedEventArgs. (This callback method is not generated automatically so the parameters should be remembered for future references). &lt;/p&gt;
&lt;p&gt;The DependencyPropertyChangedEventArgs, holds three properties &lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;NewValue &lt;/li&gt;
    &lt;li&gt;OldValue &lt;/li&gt;
    &lt;li&gt;Property &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The NewValue is the requested value to be changed, the old value is the current value that will be replaced and the property is the identifier of the property requested to be changed, if property changed callback is defined the property value will be changed as soon as the callback method is exited, or in case of a function when a true value is return (to accept the new value) or false (to reject the new value and revert the value to old value). &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;VB.NET&lt;/strong&gt;  &lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;Shared Function &lt;/span&gt;FrameworkElementValueChanged(&lt;span style="COLOR: blue"&gt;ByVal &lt;/span&gt;sender &lt;span style="COLOR: blue"&gt;As &lt;/span&gt;DependencyObject, _
                                            &lt;span style="COLOR: blue"&gt;ByVal &lt;/span&gt;e &lt;span style="COLOR: blue"&gt;As &lt;/span&gt;DependencyPropertyChangedEventArgs) &lt;span style="COLOR: blue"&gt;As Boolean
        Dim &lt;/span&gt;FwE &lt;span style="COLOR: blue"&gt;As &lt;/span&gt;FrameworkElement = &lt;span style="COLOR: blue"&gt;CType&lt;/span&gt;(sender, FrameworkElement)
        &lt;span style="COLOR: blue"&gt;Dim &lt;/span&gt;NVal &lt;span style="COLOR: blue"&gt;As Integer &lt;/span&gt;= &lt;span style="COLOR: blue"&gt;CType&lt;/span&gt;(e.NewValue, &lt;span style="COLOR: blue"&gt;Integer&lt;/span&gt;)
        &lt;span style="COLOR: blue"&gt;Dim &lt;/span&gt;OVal &lt;span style="COLOR: blue"&gt;As Integer &lt;/span&gt;= &lt;span style="COLOR: blue"&gt;CType&lt;/span&gt;(e.OldValue, &lt;span style="COLOR: blue"&gt;Integer&lt;/span&gt;)

        &lt;span style="COLOR: blue"&gt;If &lt;/span&gt;(NVal &amp;lt; FwE.Minimum) &lt;span style="COLOR: blue"&gt;Then
            Return False
        Else
            Return True
        End If

        If &lt;/span&gt;(NVal &amp;gt; FwE.Maximum) &lt;span style="COLOR: blue"&gt;Then
            Return False
        Else
            Return True
        End If

 End Function&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;strong&gt;C#&lt;/strong&gt; &lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;static bool &lt;/span&gt;FrameworkElementValueChanged(&lt;span style="COLOR: #2b91af"&gt;DependencyObject &lt;/span&gt;sender, 
            &lt;span style="COLOR: #2b91af"&gt;DependencyPropertyChangedEventArgs &lt;/span&gt;e)
        {
            &lt;span style="COLOR: #2b91af"&gt;FrameworkElement &lt;/span&gt;FwE = sender &lt;span style="COLOR: blue"&gt;as &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;FrameworkElement&lt;/span&gt;;
            &lt;span style="COLOR: blue"&gt;int &lt;/span&gt;NVal = (&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;)e.NewValue;
            &lt;span style="COLOR: blue"&gt;int &lt;/span&gt;OVal = (&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;)e.OldValue;

            &lt;span style="COLOR: blue"&gt;if &lt;/span&gt;(NVal &amp;lt; FwE.Minimum) &lt;span style="COLOR: blue"&gt;return false&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;else return true&lt;/span&gt;;

            &lt;span style="COLOR: blue"&gt;if &lt;/span&gt;(NVal &amp;gt; FwE.Maximum) &lt;span style="COLOR: blue"&gt;return false&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;else return true&lt;/span&gt;;

        }&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;Since the callbacks methods are also static, you’ll have to cast the sender as the parent class in order for you to use the other methods/properties within the class. &lt;/p&gt;
&lt;p&gt;In the above example, if the requested value change is within the Maximum and Minimum value then the new value is accepted or else it is rejected (Note: The callback method being called is a boolean function), this is where you can do your additional updates to any objects depending on the property value or raise events.  &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Property Coercion &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In WPF, Dependency Property metadata also includes a separate method for property coercion, when a value change is requested, it first execute property coercion callback which can modify the supplied value with property coercion callback, and then property changed callback is called. In Silverlight, Dependency Property metadata is very simple, as mentioned above there is no property coercion callback available, but you can get around that and coerce property value within the property changed callback. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;VB.NET&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;Shared Sub &lt;/span&gt;FrameworkElementValueChanged(&lt;span style="COLOR: blue"&gt;ByVal &lt;/span&gt;sender &lt;span style="COLOR: blue"&gt;As &lt;/span&gt;DependencyObject, _
                                        &lt;span style="COLOR: blue"&gt;ByVal &lt;/span&gt;e &lt;span style="COLOR: blue"&gt;As &lt;/span&gt;DependencyPropertyChangedEventArgs)
    &lt;span style="COLOR: blue"&gt;Dim &lt;/span&gt;FwE &lt;span style="COLOR: blue"&gt;As &lt;/span&gt;FrameworkElement = &lt;span style="COLOR: blue"&gt;CType&lt;/span&gt;(sender, FrameworkElement)
    &lt;span style="COLOR: blue"&gt;Dim &lt;/span&gt;NVal &lt;span style="COLOR: blue"&gt;As Integer &lt;/span&gt;= &lt;span style="COLOR: blue"&gt;CType&lt;/span&gt;(e.NewValue, &lt;span style="COLOR: blue"&gt;Integer&lt;/span&gt;)
    &lt;span style="COLOR: blue"&gt;Dim &lt;/span&gt;OVal &lt;span style="COLOR: blue"&gt;As Integer &lt;/span&gt;= &lt;span style="COLOR: blue"&gt;CType&lt;/span&gt;(e.OldValue, &lt;span style="COLOR: blue"&gt;Integer&lt;/span&gt;)

    &lt;span style="COLOR: blue"&gt;If &lt;/span&gt;NVal &amp;lt; FwE.Minimum &lt;span style="COLOR: blue"&gt;Then
        &lt;/span&gt;FwE.Value = FwE.Minimum
    &lt;span style="COLOR: blue"&gt;End If

    If &lt;/span&gt;NVal &amp;gt; FwE.Maximum &lt;span style="COLOR: blue"&gt;Then
        &lt;/span&gt;FwE.Value = FwE.Maximum
    &lt;span style="COLOR: blue"&gt;End If

End Sub&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;static void &lt;/span&gt;FrameworkElementValueChanged(&lt;span style="COLOR: #2b91af"&gt;DependencyObject &lt;/span&gt;sender, 
    &lt;span style="COLOR: #2b91af"&gt;DependencyPropertyChangedEventArgs &lt;/span&gt;e)
{
    &lt;span style="COLOR: #2b91af"&gt;FrameworkElement &lt;/span&gt;FwE = sender &lt;span style="COLOR: blue"&gt;as &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;FrameworkElement&lt;/span&gt;;
    &lt;span style="COLOR: blue"&gt;int &lt;/span&gt;NVal = (&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;)e.NewValue;
    &lt;span style="COLOR: blue"&gt;int &lt;/span&gt;OVal = (&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;)e.OldValue;

    &lt;span style="COLOR: blue"&gt;if&lt;/span&gt;(NVal &amp;lt; FwE.Minimum)
    {
        FwE.Value = FwE.Minimum;
    }

    &lt;span style="COLOR: blue"&gt;if&lt;/span&gt;(NVal &amp;gt; FwE.Maximum)
    {
        FwE.Value = FwE.Maximum;
    }

}&lt;/pre&gt;
&lt;p&gt;The above property changed callback is a method instead of a function, where if the requested value change falls beyond the acceptable value it will coerce the value to an acceptable value, in this example if a valid value change is requested and if it exits the method without any change then the value will be accepted. &lt;/p&gt;
&lt;h4&gt;Limitations of Dependency Property in Silverlight 2.0&lt;/h4&gt;
&lt;p&gt;Silverlight 2.0 have a very limited control and usage with Dependency Properties, and their existence in Silverlight is only to enable any value to be able to bind to the property rather than provide anything significant. There are many limitation on user defined Dependency properties in Silverlight that its almost unusable in normal circumstances, but in case of user defined custom controls it becomes a compulsion to use dependency properties since binding can only be done to a dependency property and a well built custom control should support binding. &lt;/p&gt;
&lt;p&gt;The problem with user defined Dependency Property in Silverlight 2.0 is with the ability to be bind with itself. It can bind to a Dependency Property of another class (if that class is explicitly mentioned as data context). This inability of Dependency Properties renders the use of Dependency Properties in Silverlight to almost useless. Normally (in WPF) you can use a Dependency Property just like a Attached Property, even binding is done with relative easy and user will remain transparent to anything that goes beyond, and by default the context is its own class so there is no problem with binding with itself, but in Silverlight 2.0, Dependency Properties behave differently and should only be used in exceptional circumstances (designing custom controls) and understanding the limitations. &lt;/p&gt;
&lt;p&gt;If you are considering using a Dependency Property only to notify changes to property value to UI then you can  use interface System.ComponentModel.INotifyPropertyChanged and use normal Properties instead of Dependency Properties, for example. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;VB.NET&lt;/strong&gt; &lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;Imports &lt;/span&gt;System.ComponentModel
&lt;span style="COLOR: blue"&gt;Public Class &lt;/span&gt;FrameworkElement &lt;span style="COLOR: blue"&gt;Implements &lt;/span&gt;INotifyPropertyChanged

    &lt;span style="COLOR: blue"&gt;Public Event &lt;/span&gt;PropertyChanged &lt;span style="COLOR: blue"&gt;As &lt;/span&gt;PropertyChangedEventHandler _ &lt;br /&gt; &lt;span style="COLOR: blue"&gt;                Implements &lt;/span&gt; INotifyPropertyChanged.PropertyChanged

    &lt;span style="COLOR: blue"&gt;Private &lt;/span&gt;_Value &lt;span style="COLOR: blue"&gt;As Integer

    Public Property &lt;/span&gt;Value() &lt;span style="COLOR: blue"&gt;As Integer
        Get
            Return &lt;/span&gt;_Value
        &lt;span style="COLOR: blue"&gt;End Get
        Set&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;ByVal &lt;/span&gt;value &lt;span style="COLOR: blue"&gt;As Integer&lt;/span&gt;)
            &lt;span style="COLOR: blue"&gt;If &lt;/span&gt;_Value &amp;lt;&amp;gt; value &lt;span style="COLOR: blue"&gt;Then
                &lt;/span&gt;_Value = value
                &lt;span style="COLOR: blue"&gt;RaiseEvent &lt;/span&gt;PropertyChanged(&lt;span style="COLOR: blue"&gt;Me&lt;/span&gt;, &lt;span style="COLOR: blue"&gt;New &lt;/span&gt;PropertyChangedEventArgs(&lt;span style="COLOR: #a31515"&gt;"Value"&lt;/span&gt;))
            &lt;span style="COLOR: blue"&gt;End If
        End Set
    End Property

End Class
&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;using &lt;/span&gt;System.ComponentModel;
&lt;span style="COLOR: blue"&gt;namespace &lt;/span&gt;Elements
{
   &lt;span style="COLOR: blue"&gt;public class &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;FrameworkElement &lt;/span&gt;:&lt;span style="COLOR: #2b91af"&gt; INotifyPropertyChanged
   &lt;/span&gt;{

       &lt;span style="COLOR: blue"&gt;public event &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;PropertyChangedEventHandler &lt;/span&gt;PropertyChanged;

       &lt;span style="COLOR: blue"&gt;private int &lt;/span&gt;_value;

       &lt;span style="COLOR: blue"&gt;public int &lt;/span&gt;Value
       {
           &lt;span style="COLOR: blue"&gt;get
           &lt;/span&gt;{
               &lt;span style="COLOR: blue"&gt;return &lt;/span&gt;_value;
           }
           &lt;span style="COLOR: blue"&gt;set
           &lt;/span&gt;{
               &lt;span style="COLOR: blue"&gt;if &lt;/span&gt;(_value != &lt;span style="COLOR: blue"&gt;value&lt;/span&gt;)
               {
                   _value = &lt;span style="COLOR: blue"&gt;value&lt;/span&gt;;
                   PropertyChanged(&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;, &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;PropertyChangedEventArgs&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"Value"&lt;/span&gt;));
               }
           }
       }
   }
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Since in Silverlight an object can’t be binded to any Dependency Property within its own class, its fair to assume that all Dependency Properties in Silverlight are Public. &lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Microsoft hasn’t explained the limitation on usage of Dependency Properties in Silverlight 2.0, as far as I understand it has to do with the cross platform framework of Silverlight 2.0. But  hopefully Silverlight 3.0 will support advanced Dependency Property options, at least those that we already expect from Silverlight 2.0. &lt;/p&gt;
&lt;p&gt;More on Dependency Properties and  Binding, how and why they both are related to each other in next topic to follow - Understanding: Binding in Silverlight. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=128153"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=128153" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Silverlight2/aggbug/128153.aspx" width="1" height="1" /&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=5Z6V9GeV4BY:wY8YuWxjhdA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=5Z6V9GeV4BY:wY8YuWxjhdA:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=5Z6V9GeV4BY:wY8YuWxjhdA:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?i=5Z6V9GeV4BY:wY8YuWxjhdA:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/imranshaik/~4/5Z6V9GeV4BY" height="1" width="1"/&gt;</description>
            <dc:creator>Imran Shaik</dc:creator>
            <guid isPermaLink="false">http://geekswithblogs.net/Silverlight2/archive/2008/12/24/understanding-dependency-properties-in-silverlight.aspx</guid>
            <pubDate>Wed, 24 Dec 2008 14:49:10 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Silverlight2/comments/128153.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Silverlight2/archive/2008/12/24/understanding-dependency-properties-in-silverlight.aspx#feedback</comments>
            <slash:comments>6</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/Silverlight2/comments/commentRss/128153.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Silverlight2/services/trackbacks/128153.aspx</trackback:ping>
        <feedburner:origLink>http://geekswithblogs.net/Silverlight2/archive/2008/12/24/understanding-dependency-properties-in-silverlight.aspx</feedburner:origLink></item>
        <item>
            <title>Developing Custom Controls in Silverlight 2</title>
            <category>Silverlight</category>
            <link>http://feedproxy.google.com/~r/imranshaik/~3/OvRJBfQ31w4/developing-custom-controls-in-silverlight-2.aspx</link>
            <description>&lt;h3&gt;Introduction &lt;/h3&gt;  &lt;p&gt;Creating custom controls is not as difficult as they actually appear, but before we go creating custom controls lets first look at the difference between Custom Controls (CC) and Custom User-Controls (CU). &lt;/p&gt;  &lt;p&gt;Simply put Custom Controls (CC) are skinable, themable and reusable controls that once created can be used by simply loading the assembly in any project, where are Custom User-Controls are user controls that can be reused but they can't be skinned or themed. Technically they are both difference Custom Controls inherits from (System.Windows.Controls) &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.controls(VS.95).aspx"&gt;Controls&lt;/a&gt; whereas User Controls inherits from (System.Windows.Controls.UserControl) &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.usercontrol(VS.95).aspx"&gt;UserControl&lt;/a&gt;. All controls that are used in Silverlight (eg., Button, TextBlock, TextBox) and UserControl is also a Control. &lt;/p&gt;  &lt;p&gt;Lets just start by creating a custom control and we can discuss the technicalities where they arise. I'll do this in both C# and VB.NET. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This was my first custom control I built on Silverlight 2 about couple of weeks ago, and I wrote this blog last week as well. I wanted to first introduce concepts like binding and dependency properties before I publish this, but since Microsoft have released &lt;a href="http://www.codeplex.com/Silverlight"&gt;Silverlight Toolkit&lt;/a&gt; and included NumericUpDown, this is purely academic now. But do enjoy and learn how to create Custom Controls. But the basic concepts are still going to follow. &lt;/p&gt;  &lt;h3&gt;Developing a Custom Control&lt;/h3&gt;  &lt;p&gt;In this example we'll create a custom control for NumericUpDown. Its a very simple control that can be easily built, I'll be using Microsoft Visual Studio 2008 and Microsoft Expression Blend 2 (SP1), we don't really need Expression Blend but sometimes it saves time using Expression Blend. &lt;/p&gt;  &lt;p&gt;First, we'll set up and prepare to built a custom control and to test it.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;1. Setup: &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;In Visual Studio Start a new Project with Silverlight Application Template and name it (I named it Silverlight Control Library), then select ASP.NET Web Application Project for testing. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/CustomControls_C47C/2008-10-25_141920_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="286" alt="2008-10-25_141920" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/CustomControls_C47C/2008-10-25_141920_thumb.jpg" width="424" border="0" /&gt;&lt;/a&gt; &lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/CustomControls_C47C/2008-10-25_141938_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="288" alt="2008-10-25_141938" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/CustomControls_C47C/2008-10-25_141938_thumb.jpg" width="322" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now the project for testing is ready and we need a new Silverlight Class Library Template project within the solution, so add new project and Name it (I named it Controls), this is where we'll be building our custom controls, by default you'll have a Class1.vb or Class1.cs file in the project delete the file, and add a new folder and rename it "themes" (The name of this folder is important, so keep it like it is).  &lt;/p&gt;  &lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/CustomControls_C47C/2008-10-25_142351_4.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="273" alt="2008-10-25_142351" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/CustomControls_C47C/2008-10-25_142351_thumb_1.jpg" width="426" border="0" /&gt;&lt;/a&gt; &lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/CustomControls_C47C/2008-10-25_142446_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="271" alt="2008-10-25_142446" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/CustomControls_C47C/2008-10-25_142446_thumb.jpg" width="203" border="0" /&gt;&lt;/a&gt; &lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/CustomControls_C47C/2008-10-25_142514_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="269" alt="2008-10-25_142514" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/CustomControls_C47C/2008-10-25_142514_thumb.jpg" width="202" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now add an empty xaml file in that folder and name it "generic.xaml" (Again the name is important), add the following XAML tags in the the xaml file, this is the basic shell we'll always need in building custom controls. &lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ResourceDictionary
    &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"
    &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;vsm&lt;/span&gt;&lt;span style="color: blue"&gt;="clr-namespace:System.Windows;assembly=System.Windows"&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Style&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Style&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ResourceDictionary&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;It is very important that you remember to make the generic.xaml build action as Resource, this is to make sure that the template is packed in the same assembly as the control otherwise the template wont be available. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/CustomControls_C47C/2008-10-25_210935_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="243" alt="2008-10-25_210935" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/CustomControls_C47C/2008-10-25_210935_thumb.jpg" width="266" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Add another folder and name it "NumericUpDown", this is where we'll be building our custom control. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/CustomControls_C47C/2008-10-25_142528_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="258" alt="2008-10-25_142528" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/CustomControls_C47C/2008-10-25_142528_thumb.jpg" width="427" border="0" /&gt;&lt;/a&gt; &lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/CustomControls_C47C/2008-10-25_142541_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="256" alt="2008-10-25_142541" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/CustomControls_C47C/2008-10-25_142541_thumb.jpg" width="192" border="0" /&gt;&lt;/a&gt; &lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/CustomControls_C47C/2008-10-25_142558_4.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="258" alt="2008-10-25_142558" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/CustomControls_C47C/2008-10-25_142558_thumb_1.jpg" width="193" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2: Preparing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now that the setup is complete we can start building the control but first we need to focus and gather facts about the custom control. &lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Is a Numeric Only TextBox with 2 buttons for increasing and decreasing the value. &lt;/li&gt;

  &lt;li&gt;Will have a Minimum and Maximum, along with an actual Value. &lt;/li&gt;

  &lt;li&gt;TextBox should only take numeric input along with Up/Down buttons &lt;/li&gt;

  &lt;li&gt;Optionally control can be made to use only Up/Down instead of directly entering the value in the TextBox. &lt;/li&gt;

  &lt;li&gt;When the value is changed, the control will raise an event to notify anyone listening, with its own EventArgs. &lt;/li&gt;

  &lt;li&gt;The Control should allow access and Binding on basic properties like IsEnabled, Foreground, Font Size etc. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;3: Building &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First, we'll add a Class file in "NumericUpDown" folder and name it "NumericBox", this will be the name of the control, but like I explained before all controls should inherit from Control, second you'll have to tell the compiler where default style for the control is, in order to do this we'll set the DefaultStyleKey value, so in constructor. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;NumericBox&lt;/span&gt;: &lt;span style="color: #2b91af"&gt;Control
   &lt;/span&gt;{
       &lt;span style="color: blue"&gt;public &lt;/span&gt;NumericBox()
       {
           DefaultStyleKey = &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;NumericBox&lt;/span&gt;);
       }
   }&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&lt;strong&gt;VB.NET&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;Public Class &lt;/span&gt;NumericBox
    &lt;span style="color: blue"&gt;Inherits &lt;/span&gt;Control

    &lt;span style="color: blue"&gt;Public Sub New&lt;/span&gt;()
        DefaultStyleKey = &lt;span style="color: blue"&gt;GetType&lt;/span&gt;(NumericBox)
    &lt;span style="color: blue"&gt;End Sub

End Class&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Now the constructor will look for default style in generic.xaml (under themes folder) for any style referencing to current assembly.  &lt;/p&gt;

&lt;p&gt;Now we'll expose some properties externally for anyone to bind, you should be aware that any external property you want to bind to the control should be a DependencyProperty, any property (Attached Property / Dependency Property) can be binded but the property that it is binding to should be a DependencyProperty, so to keep this control bindable we'll have to expose Dependency Properties, If you have problem following this, leave a message and I'll try to explain DependencyProperty in detail.&lt;/p&gt;

&lt;p&gt;Now, we already know that we need to expose three properties Minimum, Maximum and Value, in order for us to able to check if the values entered are valid we'll check them every time the any property is changed by using PropertyChangedCallback. (We'll implement Property Callbacks later)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;#region &lt;/span&gt;Dependency Properties
       &lt;span style="color: blue"&gt;public int &lt;/span&gt;Minimum
       {
           &lt;span style="color: blue"&gt;get &lt;/span&gt;{ &lt;span style="color: blue"&gt;return &lt;/span&gt;(&lt;span style="color: blue"&gt;int&lt;/span&gt;)GetValue(MinimumProperty); }
           &lt;span style="color: blue"&gt;set &lt;/span&gt;{ SetValue(MinimumProperty, &lt;span style="color: blue"&gt;value&lt;/span&gt;); }
       }

       &lt;span style="color: blue"&gt;public static readonly &lt;/span&gt;&lt;span style="color: #2b91af"&gt;DependencyProperty &lt;/span&gt;MinimumProperty =
           &lt;span style="color: #2b91af"&gt;DependencyProperty&lt;/span&gt;.Register(&lt;span style="color: #a31515"&gt;"Minimum"&lt;/span&gt;, &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: blue"&gt;int&lt;/span&gt;), &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;NumericBox&lt;/span&gt;), 
           &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PropertyMetadata&lt;/span&gt;(0, &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PropertyChangedCallback&lt;/span&gt;(MinimumChanged)));

       &lt;span style="color: blue"&gt;private static void &lt;/span&gt;MinimumChanged(&lt;span style="color: #2b91af"&gt;DependencyObject &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;DependencyPropertyChangedEventArgs &lt;/span&gt;e)
       {

       }

       &lt;span style="color: blue"&gt;public int &lt;/span&gt;Maximum
       {
           &lt;span style="color: blue"&gt;get &lt;/span&gt;{ &lt;span style="color: blue"&gt;return &lt;/span&gt;(&lt;span style="color: blue"&gt;int&lt;/span&gt;)GetValue(MaximumProperty); }
           &lt;span style="color: blue"&gt;set &lt;/span&gt;{ SetValue(MaximumProperty, &lt;span style="color: blue"&gt;value&lt;/span&gt;); }
       }

       &lt;span style="color: blue"&gt;public static readonly &lt;/span&gt;&lt;span style="color: #2b91af"&gt;DependencyProperty &lt;/span&gt;MaximumProperty =
           &lt;span style="color: #2b91af"&gt;DependencyProperty&lt;/span&gt;.Register(&lt;span style="color: #a31515"&gt;"Maximum"&lt;/span&gt;, &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: blue"&gt;int&lt;/span&gt;), &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;NumericBox&lt;/span&gt;), 
           &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PropertyMetadata&lt;/span&gt;(10, &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PropertyChangedCallback&lt;/span&gt;(MaximumChanged)));

       &lt;span style="color: blue"&gt;private static void &lt;/span&gt;MaximumChanged(&lt;span style="color: #2b91af"&gt;DependencyObject &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;DependencyPropertyChangedEventArgs &lt;/span&gt;e)
       {

       }

       &lt;span style="color: blue"&gt;public int &lt;/span&gt;Value
       {
           &lt;span style="color: blue"&gt;get &lt;/span&gt;{ &lt;span style="color: blue"&gt;return &lt;/span&gt;(&lt;span style="color: blue"&gt;int&lt;/span&gt;)GetValue(ValueProperty); }
           &lt;span style="color: blue"&gt;set &lt;/span&gt;{ SetValue(ValueProperty, &lt;span style="color: blue"&gt;value&lt;/span&gt;); }
       }

       &lt;span style="color: blue"&gt;public static readonly &lt;/span&gt;&lt;span style="color: #2b91af"&gt;DependencyProperty &lt;/span&gt;ValueProperty =
           &lt;span style="color: #2b91af"&gt;DependencyProperty&lt;/span&gt;.Register(&lt;span style="color: #a31515"&gt;"Value"&lt;/span&gt;, &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: blue"&gt;int&lt;/span&gt;), &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;NumericBox&lt;/span&gt;),
           &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PropertyMetadata&lt;/span&gt;(0, &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PropertyChangedCallback&lt;/span&gt;(ValueChanged)));

       &lt;span style="color: blue"&gt;private static void &lt;/span&gt;ValueChanged(&lt;span style="color: #2b91af"&gt;DependencyObject &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;DependencyPropertyChangedEventArgs &lt;/span&gt;e)
       {

       }

&lt;span style="color: blue"&gt;#endregion&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&lt;strong&gt;VB.NET&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;#Region &lt;/span&gt;&lt;span style="color: #a31515"&gt;"Dependency Properties"

    &lt;/span&gt;&lt;span style="color: blue"&gt;Public Property &lt;/span&gt;Minimum()
        &lt;span style="color: blue"&gt;Get
            Return &lt;/span&gt;GetValue(MinimumProperty)
        &lt;span style="color: blue"&gt;End Get
        Set&lt;/span&gt;(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;value)
            SetValue(MinimumProperty, value)
        &lt;span style="color: blue"&gt;End Set
    End Property

    Public Shared &lt;/span&gt;MinimumProperty &lt;span style="color: blue"&gt;As &lt;/span&gt;DependencyProperty = _
    DependencyProperty.Register(&lt;span style="color: #a31515"&gt;"Minimum"&lt;/span&gt;, &lt;span style="color: blue"&gt;GetType&lt;/span&gt;(&lt;span style="color: blue"&gt;Integer&lt;/span&gt;), &lt;span style="color: blue"&gt;GetType&lt;/span&gt;(NumericBox), _
                            &lt;span style="color: blue"&gt;New &lt;/span&gt;PropertyMetadata(0, &lt;span style="color: blue"&gt;New &lt;/span&gt;PropertyChangedCallback(&lt;span style="color: blue"&gt;AddressOf &lt;/span&gt;MinimumValueChanged)))

    &lt;span style="color: blue"&gt;Private Shared Sub &lt;/span&gt;MinimumValueChanged(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;sender &lt;span style="color: blue"&gt;As &lt;/span&gt;DependencyObject, &lt;span style="color: blue"&gt;ByVal &lt;/span&gt;e &lt;span style="color: blue"&gt;As &lt;/span&gt;DependencyPropertyChangedEventArgs)

    &lt;span style="color: blue"&gt;End Sub

    Public Property &lt;/span&gt;Maximum()
        &lt;span style="color: blue"&gt;Get
            Return &lt;/span&gt;GetValue(MaximumProperty)
        &lt;span style="color: blue"&gt;End Get
        Set&lt;/span&gt;(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;value)
            SetValue(MaximumProperty, value)
        &lt;span style="color: blue"&gt;End Set
    End Property

    Public Shared &lt;/span&gt;MaximumProperty &lt;span style="color: blue"&gt;As &lt;/span&gt;DependencyProperty = _
    DependencyProperty.Register(&lt;span style="color: #a31515"&gt;"Maximum"&lt;/span&gt;, &lt;span style="color: blue"&gt;GetType&lt;/span&gt;(&lt;span style="color: blue"&gt;Integer&lt;/span&gt;), &lt;span style="color: blue"&gt;GetType&lt;/span&gt;(NumericBox), _
                                &lt;span style="color: blue"&gt;New &lt;/span&gt;PropertyMetadata(10, &lt;span style="color: blue"&gt;New &lt;/span&gt;PropertyChangedCallback(&lt;span style="color: blue"&gt;AddressOf &lt;/span&gt;MaximumValueChanged)))

    &lt;span style="color: blue"&gt;Private Shared Sub &lt;/span&gt;MaximumValueChanged(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;sender &lt;span style="color: blue"&gt;As &lt;/span&gt;DependencyObject, &lt;span style="color: blue"&gt;ByVal &lt;/span&gt;e &lt;span style="color: blue"&gt;As &lt;/span&gt;DependencyPropertyChangedEventArgs)

    &lt;span style="color: blue"&gt;End Sub

    Public Property &lt;/span&gt;Value()
        &lt;span style="color: blue"&gt;Get
            Return &lt;/span&gt;GetValue(ValueProperty)
        &lt;span style="color: blue"&gt;End Get
        Set&lt;/span&gt;(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;value)
            SetValue(ValueProperty, value)
        &lt;span style="color: blue"&gt;End Set
    End Property

    Public Shared &lt;/span&gt;ValueProperty &lt;span style="color: blue"&gt;As &lt;/span&gt;DependencyProperty = _
    DependencyProperty.Register(&lt;span style="color: #a31515"&gt;"Value"&lt;/span&gt;, &lt;span style="color: blue"&gt;GetType&lt;/span&gt;(&lt;span style="color: blue"&gt;Integer&lt;/span&gt;), &lt;span style="color: blue"&gt;GetType&lt;/span&gt;(NumericBox), _
                                &lt;span style="color: blue"&gt;New &lt;/span&gt;PropertyMetadata(0, &lt;span style="color: blue"&gt;New &lt;/span&gt;PropertyChangedCallback(&lt;span style="color: blue"&gt;AddressOf &lt;/span&gt;ValueChanged)))

    &lt;span style="color: blue"&gt;Private Shared Sub &lt;/span&gt;ValueChanged(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;sender &lt;span style="color: blue"&gt;As &lt;/span&gt;DependencyObject, &lt;span style="color: blue"&gt;ByVal &lt;/span&gt;e &lt;span style="color: blue"&gt;As &lt;/span&gt;DependencyPropertyChangedEventArgs)


    &lt;span style="color: blue"&gt;End Sub

#End Region&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Now we have three Dependency Properties exposed, we are setting the default values here but its a good practice to also set them in Style, so we'll go to generic.xaml (after compiling the project) and add a reference to current assembly and then add them to the style. &lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ResourceDictionary
    &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"
    &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;vsm&lt;/span&gt;&lt;span style="color: blue"&gt;="clr-namespace:System.Windows;assembly=System.Windows"
    &lt;/span&gt;&lt;strong&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;local&lt;/span&gt;&lt;/strong&gt;&lt;span style="color: blue"&gt;&lt;strong&gt;="clr-namespace:Controls.NumericUpDown;assembly=Controls.NumericUpDown"&amp;gt;&lt;/strong&gt;
    
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Style &lt;/span&gt;&lt;span style="color: red"&gt;TargetType&lt;/span&gt;&lt;span style="color: blue"&gt;="local:NumericBox"&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Setter &lt;/span&gt;&lt;span style="color: red"&gt;Property&lt;/span&gt;&lt;span style="color: blue"&gt;="Minimum"  &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;="0"/&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Setter &lt;/span&gt;&lt;span style="color: red"&gt;Property&lt;/span&gt;&lt;span style="color: blue"&gt;="Maximum" &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;="10"/&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Setter &lt;/span&gt;&lt;span style="color: red"&gt;Property&lt;/span&gt;&lt;span style="color: blue"&gt;="Value" &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;="0"/&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Style&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ResourceDictionary&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Now that you understand how to expose properties, we'll first finish the job with Dependency Properties by validating the values. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt; &lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;private static void &lt;/span&gt;MinimumChanged(&lt;span style="color: #2b91af"&gt;DependencyObject &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;DependencyPropertyChangedEventArgs &lt;/span&gt;e)
{
    &lt;span style="color: #2b91af"&gt;NumericBox &lt;/span&gt;NB = sender &lt;span style="color: blue"&gt;as &lt;/span&gt;&lt;span style="color: #2b91af"&gt;NumericBox&lt;/span&gt;;

    &lt;span style="color: blue"&gt;int &lt;/span&gt;val = (&lt;span style="color: blue"&gt;int&lt;/span&gt;)e.NewValue;

    &lt;span style="color: blue"&gt;if &lt;/span&gt;(NB == &lt;span style="color: blue"&gt;null&lt;/span&gt;)
        &lt;span style="color: blue"&gt;return&lt;/span&gt;;

    &lt;span style="color: blue"&gt;if &lt;/span&gt;(val &amp;gt; NB.Maximum)
        NB.Minimum = (&lt;span style="color: blue"&gt;int&lt;/span&gt;)e.OldValue;

    &lt;span style="color: blue"&gt;if &lt;/span&gt;(NB.Value &amp;lt; val)
        NB.Value = val;
}

&lt;span style="color: blue"&gt;private static void &lt;/span&gt;MaximumChanged(&lt;span style="color: #2b91af"&gt;DependencyObject &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;DependencyPropertyChangedEventArgs &lt;/span&gt;e)
{
    &lt;span style="color: #2b91af"&gt;NumericBox &lt;/span&gt;NB = sender &lt;span style="color: blue"&gt;as &lt;/span&gt;&lt;span style="color: #2b91af"&gt;NumericBox&lt;/span&gt;;

    &lt;span style="color: blue"&gt;int &lt;/span&gt;val = (&lt;span style="color: blue"&gt;int&lt;/span&gt;)e.NewValue;

    &lt;span style="color: blue"&gt;if &lt;/span&gt;(NB == &lt;span style="color: blue"&gt;null&lt;/span&gt;)
        &lt;span style="color: blue"&gt;return&lt;/span&gt;;

    &lt;span style="color: blue"&gt;if &lt;/span&gt;(val &amp;lt; NB.Minimum)
        NB.Maximum = (&lt;span style="color: blue"&gt;int&lt;/span&gt;)e.OldValue;
}

&lt;span style="color: blue"&gt;private static void &lt;/span&gt;ValueChanged(&lt;span style="color: #2b91af"&gt;DependencyObject &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;DependencyPropertyChangedEventArgs &lt;/span&gt;e)
{
    &lt;span style="color: #2b91af"&gt;NumericBox &lt;/span&gt;NB = sender &lt;span style="color: blue"&gt;as &lt;/span&gt;&lt;span style="color: #2b91af"&gt;NumericBox&lt;/span&gt;;
    &lt;span style="color: blue"&gt;int &lt;/span&gt;val = (&lt;span style="color: blue"&gt;int&lt;/span&gt;)e.NewValue;
    &lt;span style="color: blue"&gt;if &lt;/span&gt;(NB == &lt;span style="color: blue"&gt;null&lt;/span&gt;)
        &lt;span style="color: blue"&gt;return&lt;/span&gt;;

    &lt;span style="color: blue"&gt;if &lt;/span&gt;(val &amp;lt; NB.Minimum)
    {
        NB.Value = NB.Minimum;
        NB._ValueChanged = &lt;span style="color: blue"&gt;false&lt;/span&gt;;
        &lt;span style="color: blue"&gt;return&lt;/span&gt;;
    }

    &lt;span style="color: blue"&gt;if &lt;/span&gt;(val &amp;gt; NB.Maximum)
    {
        NB.Value = NB.Maximum;
        NB._ValueChanged = &lt;span style="color: blue"&gt;false&lt;/span&gt;;
        &lt;span style="color: blue"&gt;return&lt;/span&gt;;
    }
    NB._ValueChanged = &lt;span style="color: blue"&gt;true&lt;/span&gt;;    
}&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;VB.NET &lt;/strong&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;Private Shared Sub &lt;/span&gt;MinimumValueChanged(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;sender &lt;span style="color: blue"&gt;As &lt;/span&gt;DependencyObject, &lt;span style="color: blue"&gt;ByVal &lt;/span&gt;e &lt;span style="color: blue"&gt;As &lt;/span&gt;DependencyPropertyChangedEventArgs)

    &lt;span style="color: blue"&gt;Dim &lt;/span&gt;NB &lt;span style="color: blue"&gt;As &lt;/span&gt;NumericBox = &lt;span style="color: blue"&gt;CType&lt;/span&gt;(sender, NumericBox)
    &lt;span style="color: blue"&gt;Dim &lt;/span&gt;Val &lt;span style="color: blue"&gt;As Integer &lt;/span&gt;= &lt;span style="color: blue"&gt;CType&lt;/span&gt;(e.NewValue, &lt;span style="color: blue"&gt;Integer&lt;/span&gt;)

    &lt;span style="color: blue"&gt;If &lt;/span&gt;NB &lt;span style="color: blue"&gt;Is Nothing Then Return

    If &lt;/span&gt;Val &amp;gt;= NB.Maximum &lt;span style="color: blue"&gt;Then &lt;/span&gt;NB.Minimum = &lt;span style="color: blue"&gt;CType&lt;/span&gt;(e.OldValue, &lt;span style="color: blue"&gt;Integer&lt;/span&gt;)

    &lt;span style="color: blue"&gt;If &lt;/span&gt;Val &amp;gt; NB.Value &lt;span style="color: blue"&gt;Then &lt;/span&gt;NB.Value = Val

&lt;span style="color: blue"&gt;End Sub

Private Shared Sub &lt;/span&gt;MaximumValueChanged(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;sender &lt;span style="color: blue"&gt;As &lt;/span&gt;DependencyObject, &lt;span style="color: blue"&gt;ByVal &lt;/span&gt;e &lt;span style="color: blue"&gt;As &lt;/span&gt;DependencyPropertyChangedEventArgs)

    &lt;span style="color: blue"&gt;Dim &lt;/span&gt;NB &lt;span style="color: blue"&gt;As &lt;/span&gt;NumericBox = &lt;span style="color: blue"&gt;CType&lt;/span&gt;(sender, NumericBox)
    &lt;span style="color: blue"&gt;Dim &lt;/span&gt;Val &lt;span style="color: blue"&gt;As Integer &lt;/span&gt;= &lt;span style="color: blue"&gt;CType&lt;/span&gt;(e.NewValue, &lt;span style="color: blue"&gt;Integer&lt;/span&gt;)

    &lt;span style="color: blue"&gt;If &lt;/span&gt;NB &lt;span style="color: blue"&gt;Is Nothing Then Return

    If &lt;/span&gt;Val &amp;lt;= NB.Minimum &lt;span style="color: blue"&gt;Then &lt;/span&gt;NB.Maximum = &lt;span style="color: blue"&gt;CType&lt;/span&gt;(e.OldValue, &lt;span style="color: blue"&gt;Integer&lt;/span&gt;)

    &lt;span style="color: blue"&gt;If &lt;/span&gt;Val &amp;lt; NB.Value &lt;span style="color: blue"&gt;Then &lt;/span&gt;NB.Value = Val

&lt;span style="color: blue"&gt;End Sub

Private Shared Sub &lt;/span&gt;ValueChanged(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;sender &lt;span style="color: blue"&gt;As &lt;/span&gt;DependencyObject, &lt;span style="color: blue"&gt;ByVal &lt;/span&gt;e &lt;span style="color: blue"&gt;As &lt;/span&gt;DependencyPropertyChangedEventArgs)

    &lt;span style="color: blue"&gt;Dim &lt;/span&gt;NB &lt;span style="color: blue"&gt;As &lt;/span&gt;NumericBox = &lt;span style="color: blue"&gt;CType&lt;/span&gt;(sender, NumericBox)
    &lt;span style="color: blue"&gt;Dim &lt;/span&gt;Val &lt;span style="color: blue"&gt;As Integer &lt;/span&gt;= &lt;span style="color: blue"&gt;CType&lt;/span&gt;(e.NewValue, &lt;span style="color: blue"&gt;Integer&lt;/span&gt;)

    &lt;span style="color: blue"&gt;If &lt;/span&gt;NB &lt;span style="color: blue"&gt;Is Nothing Then Return

    If &lt;/span&gt;Val &amp;lt; NB.Minimum &lt;span style="color: blue"&gt;Then
        &lt;/span&gt;NB.Value = NB.Minimum
        NB._ValueUpdated = &lt;span style="color: blue"&gt;False
        Return
    End If

    If &lt;/span&gt;Val &amp;gt; NB.Maximum &lt;span style="color: blue"&gt;Then
        &lt;/span&gt;NB.Value = NB.Maximum
        NB._ValueUpdated = &lt;span style="color: blue"&gt;False
        Return
    End If

    &lt;/span&gt;NB._ValueUpdated = &lt;span style="color: blue"&gt;True
End Sub&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Now that basic logic is in place we'll finish with the basic structure, for this we need to define template in generic.xaml to provide the building blocks of the control (i.e., the look and feel of the control).&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ResourceDictionary
    &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"
    &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;vsm&lt;/span&gt;&lt;span style="color: blue"&gt;="clr-namespace:System.Windows;assembly=System.Windows"
    &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;local&lt;/span&gt;&lt;span style="color: blue"&gt;="clr-namespace:Controls.NumericUpDown;assembly=Controls.NumericUpDown"&amp;gt;
    
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Style &lt;/span&gt;&lt;span style="color: red"&gt;TargetType&lt;/span&gt;&lt;span style="color: blue"&gt;="local:NumericBox"&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Setter &lt;/span&gt;&lt;span style="color: red"&gt;Property&lt;/span&gt;&lt;span style="color: blue"&gt;="Minimum"  &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;="0"/&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Setter &lt;/span&gt;&lt;span style="color: red"&gt;Property&lt;/span&gt;&lt;span style="color: blue"&gt;="Maximum" &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;="10"/&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Setter &lt;/span&gt;&lt;span style="color: red"&gt;Property&lt;/span&gt;&lt;span style="color: blue"&gt;="Value" &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;="1"/&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Setter &lt;/span&gt;&lt;span style="color: red"&gt;Property&lt;/span&gt;&lt;span style="color: blue"&gt;="Template"&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Setter.Value&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ControlTemplate &lt;/span&gt;&lt;span style="color: red"&gt;TargetType&lt;/span&gt;&lt;span style="color: blue"&gt;="local:NumericBox"&amp;gt;
                       &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Grid&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                          &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                              &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ColumnDefinition &lt;/span&gt;&lt;span style="color: red"&gt;Width&lt;/span&gt;&lt;span style="color: blue"&gt;="3*"/&amp;gt;
                               &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ColumnDefinition &lt;/span&gt;&lt;span style="color: red"&gt;Width&lt;/span&gt;&lt;span style="color: blue"&gt;="*"/&amp;gt;
                           &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                         &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;TextBox &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Name&lt;/span&gt;&lt;span style="color: blue"&gt;="NumericTextBox"  &lt;/span&gt;&lt;span style="color: red"&gt;Grid.Column&lt;/span&gt;&lt;span style="color: blue"&gt;="0" &lt;/span&gt;&lt;span style="color: red"&gt;Grid.ColumnSpan&lt;/span&gt;&lt;span style="color: blue"&gt;="2" &lt;/span&gt;&lt;span style="color: red"&gt;IsTabStop&lt;/span&gt;&lt;span style="color: blue"&gt;="True"
                                  &lt;/span&gt;&lt;span style="color: red"&gt;IsEnabled&lt;/span&gt;&lt;span style="color: blue"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515"&gt;TemplateBinding &lt;/span&gt;&lt;span style="color: red"&gt;IsEnabled&lt;/span&gt;&lt;span style="color: blue"&gt;}" 
                                  &lt;/span&gt;&lt;span style="color: red"&gt;Foreground&lt;/span&gt;&lt;span style="color: blue"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515"&gt;TemplateBinding &lt;/span&gt;&lt;span style="color: red"&gt;Foreground&lt;/span&gt;&lt;span style="color: blue"&gt;}"
                                  &lt;/span&gt;&lt;span style="color: red"&gt;Background&lt;/span&gt;&lt;span style="color: blue"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515"&gt;TemplateBinding &lt;/span&gt;&lt;span style="color: red"&gt;Background&lt;/span&gt;&lt;span style="color: blue"&gt;}"
&lt;/span&gt;&lt;span style="color: blue"&gt;                                  &lt;/span&gt;&lt;span style="color: red"&gt;Visibility&lt;/span&gt;&lt;span style="color: blue"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515"&gt;TemplateBinding &lt;/span&gt;&lt;span style="color: red"&gt;Visibility&lt;/span&gt;&lt;span style="color: blue"&gt;}"
                                  &lt;/span&gt;&lt;span style="color: red"&gt;Text&lt;/span&gt;&lt;span style="color: blue"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515"&gt;TemplateBinding &lt;/span&gt;&lt;span style="color: red"&gt;Value&lt;/span&gt;&lt;span style="color: blue"&gt;}"
                                  /&amp;gt;
                         &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Grid &lt;/span&gt;&lt;span style="color: red"&gt;Grid.Column&lt;/span&gt;&lt;span style="color: blue"&gt;="1"&amp;gt;
                             &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                                 &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;RowDefinition&lt;/span&gt;&lt;span style="color: blue"&gt;/&amp;gt;
                                 &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;RowDefinition&lt;/span&gt;&lt;span style="color: blue"&gt;/&amp;gt;
                             &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                             &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Button &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Name&lt;/span&gt;&lt;span style="color: blue"&gt;="ValUp" &lt;/span&gt;&lt;span style="color: red"&gt;Grid.Row&lt;/span&gt;&lt;span style="color: blue"&gt;="0" &lt;/span&gt;&lt;span style="color: red"&gt;Margin&lt;/span&gt;&lt;span style="color: blue"&gt;="0,1,1,0" &lt;/span&gt;&lt;span style="color: red"&gt;IsTabStop&lt;/span&gt;&lt;span style="color: blue"&gt;="False"
                                  &lt;/span&gt;&lt;span style="color: red"&gt;IsEnabled&lt;/span&gt;&lt;span style="color: blue"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515"&gt;TemplateBinding &lt;/span&gt;&lt;span style="color: red"&gt;IsEnabled&lt;/span&gt;&lt;span style="color: blue"&gt;}"
                                  &lt;/span&gt;&lt;span style="color: red"&gt;Background&lt;/span&gt;&lt;span style="color: blue"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515"&gt;TemplateBinding &lt;/span&gt;&lt;span style="color: red"&gt;Background&lt;/span&gt;&lt;span style="color: blue"&gt;}"
                                  &lt;/span&gt;&lt;span style="color: red"&gt;Visibility&lt;/span&gt;&lt;span style="color: blue"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515"&gt;TemplateBinding &lt;/span&gt;&lt;span style="color: red"&gt;Visibility&lt;/span&gt;&lt;span style="color: blue"&gt;}"
                                  &amp;gt;
                                 &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Path &lt;/span&gt;&lt;span style="color: red"&gt;Fill&lt;/span&gt;&lt;span style="color: blue"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515"&gt;TemplateBinding &lt;/span&gt;&lt;span style="color: red"&gt;Foreground&lt;/span&gt;&lt;span style="color: blue"&gt;}" 
                                       &lt;/span&gt;&lt;span style="color: red"&gt;Data&lt;/span&gt;&lt;span style="color: blue"&gt;="F1 M 4.81721,-3.05176e-005L 9.63441,8.3436L 2.49481e-006,8.3436L 4.81721,-3.05176e-005 Z "/&amp;gt;
                             &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Button&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                             &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Button &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Name&lt;/span&gt;&lt;span style="color: blue"&gt;="ValDown" &lt;/span&gt;&lt;span style="color: red"&gt;Grid.Row&lt;/span&gt;&lt;span style="color: blue"&gt;="1" &lt;/span&gt;&lt;span style="color: red"&gt;Margin&lt;/span&gt;&lt;span style="color: blue"&gt;="0,0,1,1" &lt;/span&gt;&lt;span style="color: red"&gt;IsTabStop&lt;/span&gt;&lt;span style="color: blue"&gt;="False"
                                     &lt;/span&gt;&lt;span style="color: red"&gt;IsEnabled&lt;/span&gt;&lt;span style="color: blue"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515"&gt;TemplateBinding &lt;/span&gt;&lt;span style="color: red"&gt;IsEnabled&lt;/span&gt;&lt;span style="color: blue"&gt;}"
                                     &lt;/span&gt;&lt;span style="color: red"&gt;Background&lt;/span&gt;&lt;span style="color: blue"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515"&gt;TemplateBinding &lt;/span&gt;&lt;span style="color: red"&gt;Background&lt;/span&gt;&lt;span style="color: blue"&gt;}"
                                     &lt;/span&gt;&lt;span style="color: red"&gt;Visibility&lt;/span&gt;&lt;span style="color: blue"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515"&gt;TemplateBinding &lt;/span&gt;&lt;span style="color: red"&gt;Visibility&lt;/span&gt;&lt;span style="color: blue"&gt;}"
                                     &amp;gt;
                                 &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Path &lt;/span&gt;&lt;span style="color: red"&gt;Fill&lt;/span&gt;&lt;span style="color: blue"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515"&gt;TemplateBinding &lt;/span&gt;&lt;span style="color: red"&gt;Foreground&lt;/span&gt;&lt;span style="color: blue"&gt;}" 
                                       &lt;/span&gt;&lt;span style="color: red"&gt;Data&lt;/span&gt;&lt;span style="color: blue"&gt;="F1 M 4.81721,8.34363L 9.63441,0L 2.49481e-006,0L 4.81721,8.34363 Z "/&amp;gt;
                             &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Button&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                         &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Grid&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                     &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Grid&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ControlTemplate&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
             &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Setter.Value&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Setter&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Style&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ResourceDictionary&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
   &lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Note that we have binded all external properties to both the TextBox or Buttons, and pay attention that the Buttons and the TextBox have names, we use these names in our control class to access these objects to access events associated with them, if for some reason the names in the control templates change (user defined template/Skinned template), the whole control will fall apart, and there is no simple way to deal with it (we can deal with this by accessing the root element and checking its children, but that is a different story)&lt;/p&gt;

&lt;p&gt;Now we have to access four events, TextBox.TextChanged, TextBox.KeyDown, ButtonUp.Click and ButtonDown.Click to do this we'll overload/override "OnApplyTemplate" Method, it has to be noted that you can't access the template from constructor, even though we set the DefaultKeyStyle in constructor so the only way to safely access the objects and capture events is to do it when the template is applied, you can get a child from the template using "GetTemplateChild" method. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;private &lt;/span&gt;&lt;span style="color: #2b91af"&gt;TextBox &lt;/span&gt;TBxNum;
&lt;span style="color: blue"&gt;private &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Button &lt;/span&gt;ButUp;
&lt;span style="color: blue"&gt;private &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Button &lt;/span&gt;ButDw;

&lt;span style="color: blue"&gt;public override void &lt;/span&gt;OnApplyTemplate()
{
    &lt;span style="color: blue"&gt;base&lt;/span&gt;.OnApplyTemplate();

    TBxNum = &lt;span style="color: blue"&gt;base&lt;/span&gt;.GetTemplateChild(&lt;span style="color: #a31515"&gt;"NumericTextBox"&lt;/span&gt;) &lt;span style="color: blue"&gt;as &lt;/span&gt;&lt;span style="color: #2b91af"&gt;TextBox&lt;/span&gt;;
    ButUp = &lt;span style="color: blue"&gt;base&lt;/span&gt;.GetTemplateChild(&lt;span style="color: #a31515"&gt;"ValUp"&lt;/span&gt;) &lt;span style="color: blue"&gt;as &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Button&lt;/span&gt;;
    ButDw = &lt;span style="color: blue"&gt;base&lt;/span&gt;.GetTemplateChild(&lt;span style="color: #a31515"&gt;"ValDown"&lt;/span&gt;) &lt;span style="color: blue"&gt;as &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Button&lt;/span&gt;;

    &lt;span style="color: blue"&gt;if &lt;/span&gt;(TBxNum == &lt;span style="color: blue"&gt;null&lt;/span&gt;)
        &lt;span style="color: blue"&gt;return&lt;/span&gt;;

    &lt;span style="color: blue"&gt;if &lt;/span&gt;(ButUp == &lt;span style="color: blue"&gt;null&lt;/span&gt;)
        &lt;span style="color: blue"&gt;return&lt;/span&gt;;

    &lt;span style="color: blue"&gt;if &lt;/span&gt;(ButDw == &lt;span style="color: blue"&gt;null&lt;/span&gt;)
        &lt;span style="color: blue"&gt;return&lt;/span&gt;;

    TBxNum.TextChanged += &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;TextChangedEventHandler&lt;/span&gt;(TBxNum_TextChanged);
    TBxNum.KeyDown += &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;KeyEventHandler&lt;/span&gt;(TBxNum_KeyDown);
    ButUp.Click += &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;RoutedEventHandler&lt;/span&gt;(ButUp_Click);
    ButDw.Click += &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;RoutedEventHandler&lt;/span&gt;(ButDw_Click);
}&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;strong&gt;VB.NET&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;Private &lt;/span&gt;TBxNum &lt;span style="color: blue"&gt;As &lt;/span&gt;TextBox
&lt;span style="color: blue"&gt;Private &lt;/span&gt;ButUp &lt;span style="color: blue"&gt;As &lt;/span&gt;Button
&lt;span style="color: blue"&gt;Private &lt;/span&gt;ButDw &lt;span style="color: blue"&gt;As &lt;/span&gt;Button


&lt;span style="color: blue"&gt;Public Overloads Overrides Sub &lt;/span&gt;OnApplyTemplate()
    &lt;span style="color: blue"&gt;MyBase&lt;/span&gt;.OnApplyTemplate()

    TBxNum = &lt;span style="color: blue"&gt;CType&lt;/span&gt;(&lt;span style="color: blue"&gt;MyBase&lt;/span&gt;.GetTemplateChild(&lt;span style="color: #a31515"&gt;"NumericTextBox"&lt;/span&gt;), TextBox)
    ButUp = &lt;span style="color: blue"&gt;CType&lt;/span&gt;(&lt;span style="color: blue"&gt;MyBase&lt;/span&gt;.GetTemplateChild(&lt;span style="color: #a31515"&gt;"ValUp"&lt;/span&gt;), Button)
    ButDw = &lt;span style="color: blue"&gt;CType&lt;/span&gt;(&lt;span style="color: blue"&gt;MyBase&lt;/span&gt;.GetTemplateChild(&lt;span style="color: #a31515"&gt;"ValDown"&lt;/span&gt;), Button)

    &lt;span style="color: blue"&gt;If &lt;/span&gt;TBxNum &lt;span style="color: blue"&gt;Is Nothing Then Return

    If &lt;/span&gt;ButUp &lt;span style="color: blue"&gt;Is Nothing Then Return

    If &lt;/span&gt;ButDw &lt;span style="color: blue"&gt;Is Nothing Then Return

    AddHandler &lt;/span&gt;TBxNum.TextChanged, &lt;span style="color: blue"&gt;AddressOf &lt;/span&gt;TBxNum_TextChanged
    &lt;span style="color: blue"&gt;AddHandler &lt;/span&gt;TBxNum.KeyDown, &lt;span style="color: blue"&gt;AddressOf &lt;/span&gt;TBxNum_KeyDown
    &lt;span style="color: blue"&gt;AddHandler &lt;/span&gt;ButUp.Click, &lt;span style="color: blue"&gt;AddressOf &lt;/span&gt;ButUp_Click
    &lt;span style="color: blue"&gt;AddHandler &lt;/span&gt;ButDw.Click, &lt;span style="color: blue"&gt;AddressOf &lt;/span&gt;ButDw_Click
&lt;span style="color: blue"&gt;End Sub&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;We need to capture Button.Click events to Up/Down the Value, but we are defining TextBox.KeyDown event to restrict the entry of non-numeric keys in the text box, and we'll update Value when the Value is typed in the TextBox, thats why we are capturing the TextBox.TextChanged Event, although we are already restricting the keyboard entry I still prefer to check if the Value entered in the TextBox is a number, and we can update the Value in one procedure. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt; &lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;void &lt;/span&gt;TBxNum_TextChanged(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;TextChangedEventArgs &lt;/span&gt;e)
{
    &lt;span style="color: blue"&gt;if &lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Single&lt;/span&gt;.IsNaN(System.&lt;span style="color: #2b91af"&gt;Convert&lt;/span&gt;.ToSingle(TBxNum.Text)))
        &lt;span style="color: blue"&gt;throw new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;NotFiniteNumberException&lt;/span&gt;(TBxNum.Text);
    &lt;span style="color: blue"&gt;else
       &lt;/span&gt;UpdateValue((&lt;span style="color: blue"&gt;int&lt;/span&gt;)System.&lt;span style="color: #2b91af"&gt;Convert&lt;/span&gt;.ToInt64(TBxNum.Text));
}

&lt;span style="color: blue"&gt;void &lt;/span&gt;TBxNum_KeyDown(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;KeyEventArgs &lt;/span&gt;e)
{
    &lt;span style="color: blue"&gt;if &lt;/span&gt;(((e.Key &amp;gt;= &lt;span style="color: #2b91af"&gt;Key&lt;/span&gt;.D0 &amp;amp;&amp;amp; e.Key &amp;lt;= &lt;span style="color: #2b91af"&gt;Key&lt;/span&gt;.D9) || (e.Key &amp;gt;= &lt;span style="color: #2b91af"&gt;Key&lt;/span&gt;.NumPad0 &amp;amp;&amp;amp; e.Key &amp;lt;= &lt;span style="color: #2b91af"&gt;Key&lt;/span&gt;.NumPad9) || e.Key == &lt;span style="color: #2b91af"&gt;Key&lt;/span&gt;.Back))
        e.Handled = &lt;span style="color: blue"&gt;false&lt;/span&gt;;
    &lt;span style="color: blue"&gt;else
    &lt;/span&gt;{
        e.Handled = &lt;span style="color: blue"&gt;true&lt;/span&gt;;
    }
}

&lt;span style="color: blue"&gt;void &lt;/span&gt;ButUp_Click(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;RoutedEventArgs &lt;/span&gt;e)
{
    UpdateValue(Value + 1);
}

&lt;span style="color: blue"&gt;void &lt;/span&gt;ButDw_Click(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;RoutedEventArgs &lt;/span&gt;e)
{
    UpdateValue(Value - 1);
}

&lt;span style="color: blue"&gt;void &lt;/span&gt;UpdateValue(&lt;span style="color: blue"&gt;int &lt;/span&gt;val)
{
    _ValueChanged  = &lt;span style="color: blue"&gt;false&lt;/span&gt;;
    Value=&lt;span style="color: blue"&gt;int&lt;/span&gt;;
    &lt;span style="color: blue"&gt;if&lt;/span&gt;(_ValueChanged) 
    {
        TBxNum.Text = Value.ToString();
    }
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&lt;strong&gt;VB.NET&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;Private Sub &lt;/span&gt;TBxNum_TextChanged(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;sender &lt;span style="color: blue"&gt;As Object&lt;/span&gt;, &lt;span style="color: blue"&gt;ByVal &lt;/span&gt;e &lt;span style="color: blue"&gt;As &lt;/span&gt;TextChangedEventArgs)
    &lt;span style="color: blue"&gt;If &lt;/span&gt;(&lt;span style="color: blue"&gt;Single&lt;/span&gt;.IsNaN(System.Convert.ToSingle(TBxNum.Text))) &lt;span style="color: blue"&gt;Then
        Throw New &lt;/span&gt;NotFiniteNumberException(TBxNum.Text)
    &lt;span style="color: blue"&gt;Else
        &lt;/span&gt;UpdateValue(&lt;span style="color: blue"&gt;CType&lt;/span&gt;(TBxNum.Text, &lt;span style="color: blue"&gt;Integer&lt;/span&gt;))
    &lt;span style="color: blue"&gt;End If
End Sub

Private Sub &lt;/span&gt;TBxNum_KeyDown(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;sender &lt;span style="color: blue"&gt;As Object&lt;/span&gt;, &lt;span style="color: blue"&gt;ByVal &lt;/span&gt;e &lt;span style="color: blue"&gt;As &lt;/span&gt;KeyEventArgs)
    &lt;span style="color: blue"&gt;If &lt;/span&gt;((e.Key &amp;gt;= Key.D0 &lt;span style="color: blue"&gt;And &lt;/span&gt;e.Key &amp;lt;= Key.D9) &lt;span style="color: blue"&gt;OrElse &lt;/span&gt;(e.Key &amp;gt;= Key.NumPad0 &lt;span style="color: blue"&gt;And &lt;/span&gt;e.Key &amp;lt;= Key.NumPad9) _
        &lt;span style="color: blue"&gt;OrElse &lt;/span&gt;e.Key = Key.Back) &lt;span style="color: blue"&gt;Then &lt;/span&gt;e.Handled = &lt;span style="color: blue"&gt;False Else &lt;/span&gt;e.Handled = &lt;span style="color: blue"&gt;True
End Sub

Private Sub &lt;/span&gt;ButUp_Click(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;sender &lt;span style="color: blue"&gt;As Object&lt;/span&gt;, &lt;span style="color: blue"&gt;ByVal &lt;/span&gt;e &lt;span style="color: blue"&gt;As &lt;/span&gt;RoutedEventArgs)
    UpdateValue(Value + 1)
&lt;span style="color: blue"&gt;End Sub

Private Sub &lt;/span&gt;ButDw_Click(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;sender &lt;span style="color: blue"&gt;As Object&lt;/span&gt;, &lt;span style="color: blue"&gt;ByVal &lt;/span&gt;e &lt;span style="color: blue"&gt;As &lt;/span&gt;RoutedEventArgs)
    UpdateValue(Value - 1)
&lt;span style="color: blue"&gt;End Sub

Private Sub &lt;/span&gt;UpdateValue(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;val &lt;span style="color: blue"&gt;As Integer&lt;/span&gt;)
    _ValueUpdated = &lt;span style="color: blue"&gt;False
    &lt;/span&gt;Value = val
    &lt;span style="color: blue"&gt;If &lt;/span&gt;_ValueUpdated &lt;span style="color: blue"&gt;Then
        &lt;/span&gt;TBxNum.Text = val
    &lt;span style="color: blue"&gt;End If
End Sub&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Now the control is up and ready for testing(don't forget to add reference to this assembly), you can make any changes to the source code as you see it fit, the only thing left is to raise an event when the value changes in case anyone is listening. For this we'll build a custom EventArgs to pass the changed value. &lt;/p&gt;

&lt;p&gt;So add another file in the folder and name it "NumericBoxChangedArgs.cs" or "NumericBoxChangedArgs.vb"  as shown below. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/CustomControls_C47C/2008-10-26_092756_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="139" alt="2008-10-26_092756" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/CustomControls_C47C/2008-10-26_092756_thumb.jpg" width="249" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Now, the NumericBoxChangedArgs class inheirts EventArgs and have a readonly property and a constructor to set the Value changed, it also have a delegate event handler with NumbericBoxChangedArgs signature. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public delegate &lt;/span&gt;NumericBoxChangedHandler(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;NumericBoxChangedArgs &lt;/span&gt;e);

&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;NumericBoxChangedArgs &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;EventArgs
&lt;/span&gt;{
    &lt;span style="color: blue"&gt;private readonly int &lt;/span&gt;_Value;

    &lt;span style="color: blue"&gt;public &lt;/span&gt;NumericBoxChangedArgs(&lt;span style="color: blue"&gt;int &lt;/span&gt;val)
    {
        _Value = val;
    }

    &lt;span style="color: blue"&gt;public int &lt;/span&gt;Value
    {
        &lt;span style="color: blue"&gt;get
        &lt;/span&gt;{
            &lt;span style="color: blue"&gt;return &lt;/span&gt;_Value;
        }
    }
}&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;VB.NET&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;Namespace &lt;/span&gt;NumericUpDown
    &lt;span style="color: blue"&gt;Public Delegate Sub &lt;/span&gt;NumericBoxChangedHandler(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;sender &lt;span style="color: blue"&gt;As Object&lt;/span&gt;, &lt;span style="color: blue"&gt;ByVal &lt;/span&gt;e &lt;span style="color: blue"&gt;As &lt;/span&gt;NumericBoxChangedArgs)

    &lt;span style="color: blue"&gt;Public Class &lt;/span&gt;NumericBoxChangedArgs
        &lt;span style="color: blue"&gt;Inherits &lt;/span&gt;EventArgs

        &lt;span style="color: blue"&gt;Private ReadOnly &lt;/span&gt;_val &lt;span style="color: blue"&gt;As Integer

        Public Sub New&lt;/span&gt;(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;val &lt;span style="color: blue"&gt;As Integer&lt;/span&gt;)
            _val = val
        &lt;span style="color: blue"&gt;End Sub

        Public ReadOnly Property &lt;/span&gt;Value() &lt;span style="color: blue"&gt;As Integer
            Get
                Return &lt;/span&gt;_val
            &lt;span style="color: blue"&gt;End Get
        End Property

    End Class
End Namespace&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Now we just declare the delegate locally and raise event in it in UpdateValue procedure. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public event &lt;/span&gt;&lt;span style="color: #2b91af"&gt;NumericBoxChangedHandler &lt;/span&gt;NumericBoxChanged;

&lt;span style="color: blue"&gt;void &lt;/span&gt;UpdateValue(&lt;span style="color: blue"&gt;int &lt;/span&gt;val)
{
    _ValueChanged  = &lt;span style="color: blue"&gt;false&lt;/span&gt;;
    Value=&lt;span style="color: blue"&gt;int&lt;/span&gt;;
    &lt;span style="color: blue"&gt;if&lt;/span&gt;(_ValueChanged) 
    {
        TBxNum.Text = Value.ToString();
        &lt;span style="color: #2b91af"&gt;NumericBoxChangedArgs &lt;/span&gt;NArgs = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;NumericBoxChangedArgs&lt;/span&gt;(Value);
        NumericBoxChanged(&lt;span style="color: blue"&gt;this&lt;/span&gt;, NArgs);
    }
}&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;strong&gt;VB.NET&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;Public Event &lt;/span&gt;NumericBoxChanged &lt;span style="color: blue"&gt;As &lt;/span&gt;NumericBoxChangedHandler

&lt;span style="color: blue"&gt;Private Sub &lt;/span&gt;UpdateValue(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;val &lt;span style="color: blue"&gt;As Integer&lt;/span&gt;)
    _ValueUpdated = &lt;span style="color: blue"&gt;False
    &lt;/span&gt;Value = val
    &lt;span style="color: blue"&gt;If &lt;/span&gt;_ValueUpdated &lt;span style="color: blue"&gt;Then
        &lt;/span&gt;TBxNum.Text = Value
        &lt;span style="color: blue"&gt;Dim &lt;/span&gt;NArgs &lt;span style="color: blue"&gt;As New &lt;/span&gt;NumericBoxChangedArgs(Value)
        &lt;span style="color: blue"&gt;RaiseEvent &lt;/span&gt;NumericBoxChanged(&lt;span style="color: blue"&gt;Me&lt;/span&gt;, NArgs)
    &lt;span style="color: blue"&gt;End If
End Sub&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;All the points mentioned while preparing the control are now achieved (I have added couple of more Dependency Properties to the source code (IncrementStep, IncrementOnly). Our Custom Numeric Up/Down Box is now complete, you can download the source code for this custom control below, if you make any modifications to the source code, please let me know. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Licence&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="http://creativecommons.org/licenses/by-nc-sa/2.0/uk/" rel="license"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" alt="Creative Commons License" src="http://i.creativecommons.org/l/by-nc-sa/2.0/uk/88x31.png" /&gt;&lt;/a&gt; 

  &lt;br /&gt;&lt;span rel="dc:type" property="dc:title" href="http://purl.org/dc/dcmitype/InteractiveResource" xmlns:dc="http://purl.org/dc/elements/1.1/"&gt;Silverlight NumericUpDown Control&lt;/span&gt; by &lt;a href="http://geekswithblogs.net/silverlight2/" rel="cc:attributionURL" property="cc:attributionName" xmlns:cc="http://creativecommons.org/ns#"&gt;Imran Shaik&lt;/a&gt; is licensed under a &lt;a href="http://creativecommons.org/licenses/by-nc-sa/2.0/uk/" rel="license"&gt;Creative Commons Attribution-Non-Commercial-Share Alike 2.0 UK: England &amp;amp; Wales License&lt;/a&gt;. 

  &lt;br /&gt;Based on a work at &lt;a href="http://www.geekswithblogs.net/silverlight2/" rel="dc:source" xmlns:dc="http://purl.org/dc/elements/1.1/"&gt;www.geekswithblogs.net&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Download Source Code/Binary&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Version 1.0 (Both VB.NET &amp;amp; C#)&lt;/p&gt;

&lt;p&gt;&lt;iframe style="border-right: #dde5e9 1px solid; padding-right: 0px; border-top: #dde5e9 1px solid; padding-left: 0px; padding-bottom: 0px; margin: 3px; border-left: #dde5e9 1px solid; width: 240px; padding-top: 0px; border-bottom: #dde5e9 1px solid; height: 66px; background-color: #ffffff" marginwidth="0" marginheight="0" src="http://cid-539474ca775d64ec.skydrive.live.com/embedrowdetail.aspx/Public/SilverlightControlLibrary.zip" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126419"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126419" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Silverlight2/aggbug/126419.aspx" width="1" height="1" /&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=OvRJBfQ31w4:7dK3mZIg-7g:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=OvRJBfQ31w4:7dK3mZIg-7g:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=OvRJBfQ31w4:7dK3mZIg-7g:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?i=OvRJBfQ31w4:7dK3mZIg-7g:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/imranshaik/~4/OvRJBfQ31w4" height="1" width="1"/&gt;</description>
            <dc:creator>Imran Shaik</dc:creator>
            <guid isPermaLink="false">http://geekswithblogs.net/Silverlight2/archive/2008/10/31/developing-custom-controls-in-silverlight-2.aspx</guid>
            <pubDate>Fri, 31 Oct 2008 05:48:24 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Silverlight2/comments/126419.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Silverlight2/archive/2008/10/31/developing-custom-controls-in-silverlight-2.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/Silverlight2/comments/commentRss/126419.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Silverlight2/services/trackbacks/126419.aspx</trackback:ping>
        <feedburner:origLink>http://geekswithblogs.net/Silverlight2/archive/2008/10/31/developing-custom-controls-in-silverlight-2.aspx</feedburner:origLink></item>
        <item>
            <title>Understanding/Developing Silverlight</title>
            <category>Silverlight</category>
            <link>http://feedproxy.google.com/~r/imranshaik/~3/yCZ1a4tGbNE/understandingdeveloping-silverlight.aspx</link>
            <description>&lt;p&gt;There are many tutorials in Silverlight over the Internet that mostly cover the basics of Silverlight but when you start getting a bit ahead you get into trouble and the real lack of tutorials or examples when you get to Intermediate level and beyond there is much to be desired especially when it comes in examples on MSDN (specifically VB.NET), so I am starting a new series which I hope will cover from basic to advanced level, and I might try to go in as much detail as possible, basically I am finding it hard to make the transition from WPF to Silverlight and this blog series will be my way of keeping notes. &lt;/p&gt;  &lt;p&gt;I might not get it right the first time or I might miss a few things so you are always welcome to correct and rectify me if I make any mistakes. The series isn't arranged in any order I'll just blog them as they leap in my mind, I might not blog some concepts but you are always welcome to post requests. &lt;/p&gt;  &lt;p&gt;In near future I hope to post atleast the following (the order may change) &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Understanding: Silverlight Binding &lt;/li&gt;    &lt;li&gt;Understanding: Silverlight Dependency Properties &lt;/li&gt;    &lt;li&gt;Understanding: Silverlight User Controls &lt;/li&gt;    &lt;li&gt;Understanding: Silverlight Custom Controls &lt;/li&gt;    &lt;li&gt;Understanding: Dynamic Silverlight &lt;/li&gt;    &lt;li&gt;Understanding: Dynamic Silverlight XAML &lt;/li&gt;    &lt;li&gt;Understanding: Silverlight Templates &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;In addition, I'll also bring you examples in Developing series which use the concepts in Understanding series and develop real-world applications both in C# and VB.NET, and in this series you might see&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Developing: Custom User Controls &lt;/li&gt;    &lt;li&gt;Developing: Custom Controls &lt;/li&gt;    &lt;li&gt;Developing: Dynamic Custom Controls &lt;/li&gt;    &lt;li&gt;Developing: Commercial Applications &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Have some patience and stay tuned.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126137"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126137" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Silverlight2/aggbug/126137.aspx" width="1" height="1" /&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=yCZ1a4tGbNE:wONDI1ZYGPU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=yCZ1a4tGbNE:wONDI1ZYGPU:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=yCZ1a4tGbNE:wONDI1ZYGPU:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?i=yCZ1a4tGbNE:wONDI1ZYGPU:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/imranshaik/~4/yCZ1a4tGbNE" height="1" width="1"/&gt;</description>
            <dc:creator>Imran Shaik</dc:creator>
            <guid isPermaLink="false">http://geekswithblogs.net/Silverlight2/archive/2008/10/26/understandingdeveloping-silverlight.aspx</guid>
            <pubDate>Sun, 26 Oct 2008 17:28:43 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Silverlight2/comments/126137.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Silverlight2/archive/2008/10/26/understandingdeveloping-silverlight.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Silverlight2/comments/commentRss/126137.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Silverlight2/services/trackbacks/126137.aspx</trackback:ping>
        <feedburner:origLink>http://geekswithblogs.net/Silverlight2/archive/2008/10/26/understandingdeveloping-silverlight.aspx</feedburner:origLink></item>
        <item>
            <title>Tutorial: Animating Custom Controls for themes using Opacity Masks</title>
            <category>Silverlight</category>
            <link>http://feedproxy.google.com/~r/imranshaik/~3/uyG5mBohHWU/tutorial-animating-custom-controls-for-themes-using-opacity-masks.aspx</link>
            <description>&lt;p&gt;As promised I'm going to show you how to animate custom controls using Opacity masks, if you are unfamiliar with Opacity masks, please check my previous blog entry: &lt;a href="http://geekswithblogs.net/Silverlight2/archive/2008/10/22/working-with-opacity-masks.aspx"&gt;Working with Opacity masks&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In this tutorial we'll create a custom button, animate it for mouse events and then still keep it flexible to them it&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Problem&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Custom controls are notorious, especially when it comes to applying themes, it is very simple to create a custom button and animate it but it all falls apart when you try to keep it flexible to apply your themes, for example you can create a button apply animations on mouse enter and pressed states but then you can't keep your colour for external binding. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Solution: &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Instead of applying animation to the colour itself you can apply animation to the opacity masks and keep the theme alive for external colour binding, here is how we'll go about it using Expression Blend . &lt;/p&gt;  &lt;p&gt;I am sorry for the audio but its pretty simple to follow.&lt;/p&gt;  &lt;p&gt;Silverlight Streaming (&lt;a href="http://silverlight.live.com"&gt;http://silverlight.live.com&lt;/a&gt;) is not working so please download the video&lt;/p&gt;  &lt;p&gt;&lt;iframe style="border-right: #dde5e9 1px solid; padding-right: 0px; border-top: #dde5e9 1px solid; padding-left: 0px; padding-bottom: 0px; margin: 3px; border-left: #dde5e9 1px solid; width: 240px; padding-top: 0px; border-bottom: #dde5e9 1px solid; height: 66px; background-color: #ffffff" marginwidth="0" marginheight="0" src="http://cid-539474ca775d64ec.skydrive.live.com/embedrowdetail.aspx/Public/OpacityMaskTutorial.wmv" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;/p&gt;  &lt;p&gt;Note: At 2:20 I copied and pasted another Rectangle on back of the the main rectangle and coloured it black to avoid the transparency of opacity mask, it is a good practice in order to avoid making the button (or control in general) transparent, don't forget to experiment the background by using &lt;a href="http://geekswithblogs.net/Silverlight2/archive/2008/10/21/more-xaml-gradients.aspx"&gt;gradient brushes published before&lt;/a&gt; (Tip: With this Opacity Mask try the Large set of gradients for good effect). &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Download&lt;/strong&gt;&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:757a628a-3a2f-4394-942c-b38c9b2e7df4" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;p&gt;Download Source code &lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/AnimatingCustomControlsusingOpacityMasks_11DB5/ThemedButton.zip" target="_blank"&gt;(ThemedButton.Zip 34KB) &lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126075"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126075" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Silverlight2/aggbug/126075.aspx" width="1" height="1" /&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=uyG5mBohHWU:fUBLK6YMeb0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=uyG5mBohHWU:fUBLK6YMeb0:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=uyG5mBohHWU:fUBLK6YMeb0:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?i=uyG5mBohHWU:fUBLK6YMeb0:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/imranshaik/~4/uyG5mBohHWU" height="1" width="1"/&gt;</description>
            <dc:creator>Imran Shaik</dc:creator>
            <guid isPermaLink="false">http://geekswithblogs.net/Silverlight2/archive/2008/10/24/tutorial-animating-custom-controls-for-themes-using-opacity-masks.aspx</guid>
            <pubDate>Fri, 24 Oct 2008 16:55:41 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Silverlight2/comments/126075.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Silverlight2/archive/2008/10/24/tutorial-animating-custom-controls-for-themes-using-opacity-masks.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Silverlight2/comments/commentRss/126075.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Silverlight2/services/trackbacks/126075.aspx</trackback:ping>
        <feedburner:origLink>http://geekswithblogs.net/Silverlight2/archive/2008/10/24/tutorial-animating-custom-controls-for-themes-using-opacity-masks.aspx</feedburner:origLink></item>
        <item>
            <title>Working with Opacity Masks</title>
            <category>Silverlight</category>
            <link>http://feedproxy.google.com/~r/imranshaik/~3/r2w6BAkn0CY/working-with-opacity-masks.aspx</link>
            <description>&lt;p&gt;Opacity Masks are a great addition to Silverlight even thought it was there from the beginning, they are not as much helpful as otherwise they might be due to the lack of brushes in Silverlight (compared to WPF). And the addition of Alpha along with RGB in colour definition, opacity masks don't really gain much attention as they deserve. Although the use of Opacity Masks in Silverlight is very limited it is nonetheless a less important features, especially in animations and applying both vertical and horizontal gradients or both linier and radial gradient to the same object let us from start with looking at what opacity masks are and then how opacity masks are helpful in applying both vertical and horizontal gradients to the same object.&lt;/p&gt;  &lt;p&gt;As you might already know that you can only attach one single colour schema (Either Solid colour or gradients) to an object, so we'll first begin with looking at what opacity masks are. &lt;/p&gt;  &lt;h3&gt;Opacity Masks. &lt;/h3&gt;  &lt;p&gt;First we'll look at what opacity masks do on a solid colour, and then we'll go in detail with complex gradients. &lt;/p&gt;  &lt;p&gt; &lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/WorkingwithOpacityMasks_10197/2008-10-22_192437_2.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="101" alt="2008-10-22_192437" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/WorkingwithOpacityMasks_10197/2008-10-22_192437_thumb.jpg" width="197" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Image 1: Rectangle with Solid colour&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Rectangle &lt;/span&gt;&lt;span style="color: red"&gt;Fill&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF0B1BC6" &lt;/span&gt;&lt;span style="color: red"&gt;Stroke&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF000000" &lt;/span&gt;&lt;span style="color: red"&gt;RadiusX&lt;/span&gt;&lt;span style="color: blue"&gt;="8" &lt;/span&gt;&lt;span style="color: red"&gt;RadiusY&lt;/span&gt;&lt;span style="color: blue"&gt;="8"/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Now I have an object with solid colour (Rectangle with Colour FF0B1BC6 in this case) and lets say that we want to apply some transparency to the the object either at the beginning or at the end, so since Silverlight have Alpha channel in its colour definition along with RGB definition its simple to use it, Since we are dealing with a solid colour here its easy to just create a liner gradient with alpha reduced e.g., &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/WorkingwithOpacityMasks_10197/2008-10-22_192457_2.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="101" alt="2008-10-22_192457" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/WorkingwithOpacityMasks_10197/2008-10-22_192457_thumb.jpg" width="202" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Image 2: Rectangle with Linear gradient with opacity&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Rectangle&lt;/span&gt;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;RadiusX&lt;/span&gt;&lt;span style="color: blue"&gt;="8" &lt;/span&gt;&lt;span style="color: red"&gt;RadiusY&lt;/span&gt;&lt;span style="color: blue"&gt;="8" &lt;/span&gt;&lt;span style="color: red"&gt;Stroke&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF000000"&amp;gt;&lt;/span&gt;&lt;span style="color: blue"&gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Rectangle.Fill&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush &lt;/span&gt;&lt;span style="color: red"&gt;EndPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,1" &lt;/span&gt;&lt;span style="color: red"&gt;StartPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,0"&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#7F&lt;strong&gt;0B1BC6&lt;/strong&gt;"/&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF&lt;strong&gt;0B1BC6&lt;/strong&gt;" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="1"/&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Rectangle.Fill&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Rectangle&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Notice the Colour between two gradient stops they are the same colour (0B0BC6) the only difference is the Alpha (7F and FF), at offset 0 (beginning of the gradient) we have 50% opacity and at the offset 1 (end of the gradient) we have 100% opacity. &lt;/p&gt;

&lt;p&gt;It works but we can also achieve he same by applying opacity mask to the rectangle in Image 1, &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/WorkingwithOpacityMasks_10197/2008-10-22_193332_2.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="100" alt="2008-10-22_193332" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/WorkingwithOpacityMasks_10197/2008-10-22_193332_thumb.jpg" width="194" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Image 3: Rectangle with opacity mask &lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Rectangle &lt;/span&gt;&lt;span style="color: red"&gt;Fill&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF0B1BC6" &lt;/span&gt;&lt;span style="color: red"&gt;Stroke&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF000000" &lt;/span&gt;&lt;span style="color: red"&gt;RadiusX&lt;/span&gt;&lt;span style="color: blue"&gt;="8" &lt;/span&gt;&lt;span style="color: red"&gt;RadiusY&lt;/span&gt;&lt;span style="color: blue"&gt;="8"&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Rectangle.OpacityMask&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush &lt;/span&gt;&lt;span style="color: red"&gt;EndPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,1" &lt;/span&gt;&lt;span style="color: red"&gt;StartPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,0"&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#7F000000" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0"/&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFFFFFFF" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="1"/&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Rectangle.OpacityMask&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Rectangle&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Notice Image 2 and Image 3, the difference isn't much, infact technically there isn't any difference because both of them are one and the same, the only difference is applying the opacity mask to a solid colour have achieved the same results as actually applying a gradient. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Uses of Opacity Mask&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;You might ask well if we can achieve the same results with both gradient and applying opacity mask then why use opacity mask, well the advantages of opacity masks are very clear, consider this you can only apply one gradient to an object but with the addition of opacity mask you can achieve both at the same time. &lt;/p&gt;

&lt;p&gt;Here is an example, &lt;/p&gt;

&lt;p&gt;Consider the following gradient &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/WorkingwithOpacityMasks_10197/2008-10-22_194405_2.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="95" alt="2008-10-22_194405" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/WorkingwithOpacityMasks_10197/2008-10-22_194405_thumb.jpg" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Image 4: Rectangle with liner gradient from left to right &lt;/p&gt;

&lt;p&gt;Now consider that we want darken the rectangle on the top and leave the bottom the same, given that we can only apply one gradient for a single object, so to achieve this we'll have to put the another rectangle on top of that with a black gradient running from top to bottom, and  giving the top about 50% opacity and the bottom 0% opacity. &lt;/p&gt;

&lt;p&gt;Instead we can use opacity masks to achieve this, &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/WorkingwithOpacityMasks_10197/2008-10-22_195548_2.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="87" alt="2008-10-22_195548" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/WorkingwithOpacityMasks_10197/2008-10-22_195548_thumb.jpg" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Image 5: Rectangle gradient (left to right) with opacity mask (top to bottom)&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Rectangle&lt;/span&gt;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;RadiusX&lt;/span&gt;&lt;span style="color: blue"&gt;="8" &lt;/span&gt;&lt;span style="color: red"&gt;RadiusY&lt;/span&gt;&lt;span style="color: blue"&gt;="8" &lt;/span&gt;&lt;span style="color: red"&gt;Stroke&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF000000"&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Rectangle.OpacityMask&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush &lt;/span&gt;&lt;span style="color: red"&gt;EndPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,1" &lt;/span&gt;&lt;span style="color: red"&gt;StartPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,0"&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#7E000000" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.4"/&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF000000" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="1"/&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#B2000000" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5"/&amp;gt;
                &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
            &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Rectangle.OpacityMask&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Rectangle.Fill&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush &lt;/span&gt;&lt;span style="color: red"&gt;EndPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="1.,0.5" &lt;/span&gt;&lt;span style="color: red"&gt;StartPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0,0.5" &amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFC60B0B" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0"/&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFC60B0B" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="1"/&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFAAB30C" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.175"/&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FE3B8C41" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.31"/&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FE2E6C6F" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.48"/&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FE21258D" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.70"/&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FE9E19A1" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.85"/&amp;gt;
                &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
            &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Rectangle.Fill&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Rectangle&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;This trick is usually used in making the glass effects with gradients, and it is limited to dark backgrounds since in reality the opacity mask is actually making the object transparent than actually making it darker or lighter, which brings us to another usage of opacity masks. &lt;/p&gt;

&lt;p&gt;Partially transparent objects, captures the imagination, and you can achieve them using opacity masks, for example consider the following image, its the same rectangle in Image 5 over other rectangles. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/WorkingwithOpacityMasks_10197/2008-10-22_200437_2.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="140" alt="2008-10-22_200437" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/WorkingwithOpacityMasks_10197/2008-10-22_200437_thumb.jpg" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;Objects using Opacity Masks &lt;/h3&gt;

&lt;p&gt;Opacity masks are not limited to objects rectangles or paths or gradients, opacity masks can also be applied to various objects to give partial transparency, including and not limited to images and vides infact you can apply opacity masks to all UI elements and you can apply any brush (Graident brush/image brush/Video Brush etc.) as a base for opacity mask. &lt;/p&gt;

&lt;p&gt;Opacity Masks in Silverlight 2 are limited since other brushes (those available in WPF) are not available in Silverlight, but probably probably they might be avialble in future versions of Silverlight. &lt;/p&gt;

&lt;h3&gt;Opacity Masks and animation and themes &lt;/h3&gt;

&lt;p&gt;One of the areas where I usually use opacity masks are in themes and animation, I'll soon post a tutorial on using opacity masks in animation/ themes and in creating custom controls and templates, watch this space. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126022"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126022" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Silverlight2/aggbug/126022.aspx" width="1" height="1" /&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=r2w6BAkn0CY:9863oRwbn6I:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=r2w6BAkn0CY:9863oRwbn6I:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=r2w6BAkn0CY:9863oRwbn6I:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?i=r2w6BAkn0CY:9863oRwbn6I:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/imranshaik/~4/r2w6BAkn0CY" height="1" width="1"/&gt;</description>
            <dc:creator>Imran Shaik</dc:creator>
            <guid isPermaLink="false">http://geekswithblogs.net/Silverlight2/archive/2008/10/22/working-with-opacity-masks.aspx</guid>
            <pubDate>Thu, 23 Oct 2008 01:17:39 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Silverlight2/comments/126022.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Silverlight2/archive/2008/10/22/working-with-opacity-masks.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Silverlight2/comments/commentRss/126022.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Silverlight2/services/trackbacks/126022.aspx</trackback:ping>
        <feedburner:origLink>http://geekswithblogs.net/Silverlight2/archive/2008/10/22/working-with-opacity-masks.aspx</feedburner:origLink></item>
        <item>
            <title>More XAML Gradients</title>
            <category>Silverlight</category>
            <link>http://feedproxy.google.com/~r/imranshaik/~3/omIVGj8MCe4/more-xaml-gradients.aspx</link>
            <description>&lt;p&gt;This is my second lot of Gradients they are few more but that is for some other day, here are about 14 new gradients for you, I need some patience and inspiration to make few so I might come back with more. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/MoreXAMLGradients_F2C0/2008-10-21_165944_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="395" alt="2008-10-21_165944" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/MoreXAMLGradients_F2C0/2008-10-21_165944_thumb.jpg" width="308" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h3&gt;XAML: &lt;/h3&gt;  &lt;pre class="code"&gt;    &lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Key&lt;/span&gt;&lt;span style="color: blue"&gt;="CyanThemeBG" &lt;/span&gt;&lt;span style="color: red"&gt;EndPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,1" &lt;/span&gt;&lt;span style="color: red"&gt;StartPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,0"&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFC6ECFE"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF003FFF" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="1"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF37AFF9" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF0076DB" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5"/&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Key&lt;/span&gt;&lt;span style="color: blue"&gt;="MagentaBG" &lt;/span&gt;&lt;span style="color: red"&gt;EndPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,1" &lt;/span&gt;&lt;span style="color: red"&gt;StartPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,0"&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFFFCFFB" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF930E2F" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="1"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFFF659D" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFC7174B" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5"/&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Key&lt;/span&gt;&lt;span style="color: blue"&gt;="BlackBG" &lt;/span&gt;&lt;span style="color: red"&gt;EndPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,1" &lt;/span&gt;&lt;span style="color: red"&gt;StartPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,0"&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFE5E7FA"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF747C8D" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF000000" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF0F0F0F" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="1"/&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Key&lt;/span&gt;&lt;span style="color: blue"&gt;="LightBG" &lt;/span&gt;&lt;span style="color: red"&gt;EndPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,1" &lt;/span&gt;&lt;span style="color: red"&gt;StartPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,0"&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFE5E7FA"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFE3E6F5" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFD5DBF1" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFE1E4FF" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="1"/&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Key&lt;/span&gt;&lt;span style="color: blue"&gt;="TealGreen" &lt;/span&gt;&lt;span style="color: red"&gt;EndPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,1" &lt;/span&gt;&lt;span style="color: red"&gt;StartPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,0"&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFE3FCA9" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF82B03C" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="1"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFD8FA6C" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFE0FF98" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5"/&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Key&lt;/span&gt;&lt;span style="color: blue"&gt;="CyanLargeBG" &lt;/span&gt;&lt;span style="color: red"&gt;EndPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,1" &lt;/span&gt;&lt;span style="color: red"&gt;StartPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,0"&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF003FFF" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="1"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF37AFF9" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0"/&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Key&lt;/span&gt;&lt;span style="color: blue"&gt;="MagentaLargeBG" &lt;/span&gt;&lt;span style="color: red"&gt;EndPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,1" &lt;/span&gt;&lt;span style="color: red"&gt;StartPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,0"&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF930E2F" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="1"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFFF659D" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0"/&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Key&lt;/span&gt;&lt;span style="color: blue"&gt;="LightLargeBG" &lt;/span&gt;&lt;span style="color: red"&gt;EndPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,1" &lt;/span&gt;&lt;span style="color: red"&gt;StartPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,0"&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFE3E6F5" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF9D9D9D" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="1"/&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Key&lt;/span&gt;&lt;span style="color: blue"&gt;="GreenLargeBG" &lt;/span&gt;&lt;span style="color: red"&gt;EndPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,1" &lt;/span&gt;&lt;span style="color: red"&gt;StartPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,0"&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF82B03C" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="1"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFD8FA6C" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0"/&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Key&lt;/span&gt;&lt;span style="color: blue"&gt;="PurpleBG" &lt;/span&gt;&lt;span style="color: red"&gt;EndPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,1" &lt;/span&gt;&lt;span style="color: red"&gt;StartPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,0"&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFB0B8FF"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF747C8D" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF000000" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF151733" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="1"/&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Key&lt;/span&gt;&lt;span style="color: blue"&gt;="DarkGreen" &lt;/span&gt;&lt;span style="color: red"&gt;EndPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,1" &lt;/span&gt;&lt;span style="color: red"&gt;StartPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,0"&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFB0FFC4"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF5D645F" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF000000" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF15331F" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="1"/&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Key&lt;/span&gt;&lt;span style="color: blue"&gt;="DarkYellow" &lt;/span&gt;&lt;span style="color: red"&gt;EndPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,1" &lt;/span&gt;&lt;span style="color: red"&gt;StartPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,0"&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFF3FFB0"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF63645D" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF000000" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF2F3315" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="1"/&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Key&lt;/span&gt;&lt;span style="color: blue"&gt;="DarkGrape" &lt;/span&gt;&lt;span style="color: red"&gt;EndPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,1" &lt;/span&gt;&lt;span style="color: red"&gt;StartPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,0"&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFFFB0FD"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF8D7485" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF000000" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF331532" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="1"/&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Key&lt;/span&gt;&lt;span style="color: blue"&gt;="DarkBrown" &lt;/span&gt;&lt;span style="color: red"&gt;EndPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,1" &lt;/span&gt;&lt;span style="color: red"&gt;StartPoint&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5,0"&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FFFFEAB0"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF8D8774" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF000000" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="0.5"/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;GradientStop &lt;/span&gt;&lt;span style="color: red"&gt;Color&lt;/span&gt;&lt;span style="color: blue"&gt;="#FF332A15" &lt;/span&gt;&lt;span style="color: red"&gt;Offset&lt;/span&gt;&lt;span style="color: blue"&gt;="1"/&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;Usage Syntax:&lt;/h3&gt;

&lt;p&gt;Its very simple just use above lines in App.xaml under &amp;lt;Application.Resources&amp;gt; and then you can use them any where in your project &lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Rectangle &lt;/span&gt;&lt;span style="color: blue"&gt;... &lt;/span&gt;&lt;span style="color: red"&gt;Fill&lt;/span&gt;&lt;span style="color: blue"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515"&gt;StaticResource &lt;/span&gt;&lt;span style="color: red"&gt;DarkBrown&lt;/span&gt;&lt;span style="color: blue"&gt;}"/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;h3&gt;Download:&lt;/h3&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div class="wlWriterSmartContent" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:6a990a3f-5d8a-46e1-849f-310b6408bb27" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;p&gt;XAML Resource (0.5 KB) &lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/MoreXAMLGradients_F2C0/Gradients2.zip" target="_blank"&gt;Download ZIP&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=125977"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=125977" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Silverlight2/aggbug/125977.aspx" width="1" height="1" /&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=omIVGj8MCe4:QeR-eMjSH5A:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=omIVGj8MCe4:QeR-eMjSH5A:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=omIVGj8MCe4:QeR-eMjSH5A:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?i=omIVGj8MCe4:QeR-eMjSH5A:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/imranshaik/~4/omIVGj8MCe4" height="1" width="1"/&gt;</description>
            <dc:creator>Imran Shaik</dc:creator>
            <guid isPermaLink="false">http://geekswithblogs.net/Silverlight2/archive/2008/10/21/more-xaml-gradients.aspx</guid>
            <pubDate>Tue, 21 Oct 2008 22:19:11 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Silverlight2/comments/125977.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Silverlight2/archive/2008/10/21/more-xaml-gradients.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/Silverlight2/comments/commentRss/125977.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Silverlight2/services/trackbacks/125977.aspx</trackback:ping>
        <feedburner:origLink>http://geekswithblogs.net/Silverlight2/archive/2008/10/21/more-xaml-gradients.aspx</feedburner:origLink></item>
        <item>
            <title>First Reaction to Silverlight 2 RTW</title>
            <category>Silverlight</category>
            <link>http://feedproxy.google.com/~r/imranshaik/~3/Q1gvMdEOxN4/first-reaction-to-silverlight-2-rtw.aspx</link>
            <description>&lt;p&gt;I can just say that I'm happy to say good bye to Blend 2.5, it was really a pain to use to different Blend versions (2.0 and 2.5 as I mostly work on WPF) and since already bought the Expression Studio I was wondering if I had to buy Blend 2.5 just for Silverlight but now I am happy.&lt;/p&gt;  &lt;p&gt;I might bring new tutorials and now that we have a stable version it will be better I was just waiting for the final and stable release so as to kick start developing commercial Silverlight applications.&lt;/p&gt;  &lt;p&gt;I must add that since Silverlight 2 Beta 1 was released and my dissatisfaction was confirmed I really lost heart on Silverlight but full credit to Microsoft on updating Silverlight versions to its final release its more or less what I wanted, but I still have some unfortunate dissatisfaction with the final release, mostly the same issues as I had in Silverlight 2 Beta 1 (Keyboard entry in fullscreen mode, Sync calls to web services, Routed Events, Brushes) but things have changed a bit and there is always scope for improvement, I think I just have to hold them back till Silverlight 3 more likely to be 2010. &lt;/p&gt;  &lt;p&gt;At any rate I was testing Binding with Dependency Property today and was completely surprised at the lack of support in Silverlight, I'll post my findings soon, plus there are few sample that I wrote on Silverlight 2 Beta 1 that I haven't posted, which I'll do soon. &lt;/p&gt;  &lt;p&gt;Anyway, I haven't tested the full extent of Silverlight 2 and Blend, but now I'm onto it. Like I mentioned earlier since some of my previous projects I have undertaken I have also learned C#, so that is another arsenal I have now but I don't know what you guys want when I started with Silverlight on my &lt;a href="http://silverlight2.blogspot.com/"&gt;previous blog&lt;/a&gt; I was the only one to provide Silverlight samples on VB.NET, so if you prefer VB.NET instead of C# then please contact me. I must add that I'll still be using VB.NET (VB Literals) in examples for handling XML data in Silverlight, and some other techniques/ideas I have under my sleeve (mostly writing dynamic XAML using VB Literals). &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=125894"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=125894" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Silverlight2/aggbug/125894.aspx" width="1" height="1" /&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=Q1gvMdEOxN4:y_uAVbfrTpo:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=Q1gvMdEOxN4:y_uAVbfrTpo:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=Q1gvMdEOxN4:y_uAVbfrTpo:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?i=Q1gvMdEOxN4:y_uAVbfrTpo:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/imranshaik/~4/Q1gvMdEOxN4" height="1" width="1"/&gt;</description>
            <dc:creator>Imran Shaik</dc:creator>
            <guid isPermaLink="false">http://geekswithblogs.net/Silverlight2/archive/2008/10/17/first-reaction-to-silverlight-2-rtw.aspx</guid>
            <pubDate>Fri, 17 Oct 2008 05:33:39 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Silverlight2/comments/125894.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Silverlight2/archive/2008/10/17/first-reaction-to-silverlight-2-rtw.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/Silverlight2/comments/commentRss/125894.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Silverlight2/services/trackbacks/125894.aspx</trackback:ping>
        <feedburner:origLink>http://geekswithblogs.net/Silverlight2/archive/2008/10/17/first-reaction-to-silverlight-2-rtw.aspx</feedburner:origLink></item>
        <item>
            <title>Silverlight 2 Released And I'm Back...</title>
            <category>Silverlight</category>
            <link>http://feedproxy.google.com/~r/imranshaik/~3/Erhif5rTYfQ/silverlight-2-released-and-im-back.aspx</link>
            <description>&lt;p&gt;Well, finally &lt;a href="http://timheuer.com/blog/archive/2008/10/14/silverlight-2-released-officially.aspx"&gt;Silverlight 2.0 is released&lt;/a&gt;, all these months (years?) of waiting and the day has finally arrived. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Emm... Where was I? &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Busy as usual, but more to the point Silverlight 2 Beta didn't live upto my expectations and there were changing things up and down, right and left that I had to give myself a break... in the mean time I also learned C# so most of my work now will be on C# and VB.NET. &lt;/p&gt;  &lt;p&gt;Expect regular blogs from now.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=125834"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=125834" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Silverlight2/aggbug/125834.aspx" width="1" height="1" /&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=Erhif5rTYfQ:4jR7jwYpG-c:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=Erhif5rTYfQ:4jR7jwYpG-c:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=Erhif5rTYfQ:4jR7jwYpG-c:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?i=Erhif5rTYfQ:4jR7jwYpG-c:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/imranshaik/~4/Erhif5rTYfQ" height="1" width="1"/&gt;</description>
            <dc:creator>Imran Shaik</dc:creator>
            <guid isPermaLink="false">http://geekswithblogs.net/Silverlight2/archive/2008/10/14/silverlight-2-released-and-im-back.aspx</guid>
            <pubDate>Tue, 14 Oct 2008 20:53:25 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Silverlight2/comments/125834.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Silverlight2/archive/2008/10/14/silverlight-2-released-and-im-back.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Silverlight2/comments/commentRss/125834.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Silverlight2/services/trackbacks/125834.aspx</trackback:ping>
        <feedburner:origLink>http://geekswithblogs.net/Silverlight2/archive/2008/10/14/silverlight-2-released-and-im-back.aspx</feedburner:origLink></item>
        <item>
            <title>XML Literals and Embedded Expressions</title>
            <category>Silverlight</category>
            <category>WPF</category>
            <link>http://feedproxy.google.com/~r/imranshaik/~3/tLZ5UhU_Ojk/xml-literals-and-embedded-expressions.aspx</link>
            <description>&lt;p&gt;In our &lt;a href="http://geekswithblogs.net/Silverlight2/archive/2008/03/25/silverlight-2-beta-1---web-services-in-quotnew-schoolquot.aspx"&gt;previous tutorial&lt;/a&gt; we have seen how we can use XML axis properties to consume XML returned from a web service in Silverlight applications, in this example however we will look at how XML Literals and Embedded Expressions can be used to easily write fast and efficient Web Services. &lt;/p&gt;  &lt;p&gt;*Note XML Literals and Embedded Expression are Visual Basic 9 Exclusive features you might need Visual Studio 2008 and .NET Framework 3.5 installed. &lt;/p&gt;  &lt;p&gt;XML Literals and Embedded Expression are not limited to Silverlight/WPF you can use it where ever you want as long as you are using Visual Basic 9 with Visual Studio 2008. &lt;/p&gt;  &lt;h2&gt;XML Literals &lt;/h2&gt;  &lt;p&gt;So, what is XML Literals? XML literals is a nice and clean way to write XML in Visual Basic, to use XML Literals "option infer" should be set "on", before we look at XML Literals, a little about literals, what are literals, for any VB.NET programmer the following code should be very familiar. &lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;Dim &lt;/span&gt;Product = &lt;span style="color: #a31515"&gt;"Visual Basic"
&lt;/span&gt;&lt;span style="color: blue"&gt;Dim &lt;/span&gt;Version = 9
&lt;span style="color: blue"&gt;Dim &lt;/span&gt;SubVersion = 9.0
&lt;span style="color: blue"&gt;Dim &lt;/span&gt;ThisTime = #3/30/2008 3:02:00 PM#
&lt;span style="color: blue"&gt;Dim &lt;/span&gt;Tomarrow = #3/31/2008#&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Here, I am not declaring the type of the variable, but literals allow VB to understand that Product is a string,  version is integer, subversion is double, Thistime is DataTime and Tomarrow is Date, the values that I have provided are called literals, now it should be easy to understand when I say VB 9 supports XML Literals. So instead of using quotes and escape quotes to construct XML we can simple use XML literals and just start writing XML, the following is absolutely legitimate. &lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;Dim &lt;/span&gt;Products = _
&lt;span style="color: #6464b9"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;VisualStudio &lt;/span&gt;&lt;span style="color: #b96464"&gt;Version&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;2008&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;Products&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;Language &lt;/span&gt;&lt;span style="color: #b96464"&gt;Name&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;Visual Basic&lt;/span&gt;&lt;span style="color: #555555"&gt;" &lt;/span&gt;&lt;span style="color: #b96464"&gt;Version&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;9&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;/&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;Language &lt;/span&gt;&lt;span style="color: #b96464"&gt;Name&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;C#&lt;/span&gt;&lt;span style="color: #555555"&gt;" &lt;/span&gt;&lt;span style="color: #b96464"&gt;Version&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;3&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;/&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #844646"&gt;Products&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #844646"&gt;VisualStudio&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Yes, no more escape quote to construct XML, just start writing it there and then. &lt;/p&gt;

&lt;h2&gt;Embedded Expressions &lt;/h2&gt;

&lt;p&gt;Now, you might argue that we don't use XML inside the programs, we just need a clean way to manipulate XML not define them in our programs, but I never said we are finished with it, there is more. &lt;/p&gt;

&lt;p&gt;In our previous example we used XDocuments/XElement/XAttribute to write XML in our web service, which can also be used to write XML in C#&lt;/p&gt;

&lt;p&gt;This is what we had,&lt;/p&gt;

&lt;pre class="code"&gt;&amp;lt;WebMethod()&amp;gt; _
   &lt;span style="color: blue"&gt;Public Function &lt;/span&gt;AllCountries() &lt;span style="color: blue"&gt;As String

       Dim &lt;/span&gt;sud &lt;span style="color: blue"&gt;As New &lt;/span&gt;CountryDataSetTableAdapters.CountryTableTableAdapter

       &lt;span style="color: blue"&gt;Dim &lt;/span&gt;XDataSet &lt;span style="color: blue"&gt;As New &lt;/span&gt;CountryDataSet.CountryTableDataTable

       sud.Fill(XDataSet)

       &lt;span style="color: blue"&gt;Dim &lt;/span&gt;MyNameSpace &lt;span style="color: blue"&gt;As &lt;/span&gt;XNamespace = &lt;span style="color: #a31515"&gt;"http://tempuri.org/Schema/Countries/"

       &lt;/span&gt;&lt;span style="color: blue"&gt;Dim &lt;/span&gt;XDoc &lt;span style="color: blue"&gt;As &lt;/span&gt;XDocument = &lt;span style="color: blue"&gt;New &lt;/span&gt;XDocument(&lt;span style="color: blue"&gt;New &lt;/span&gt;XDeclaration(&lt;span style="color: #a31515"&gt;"1.0"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"utf-8"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"yes"&lt;/span&gt;), _
                                             &lt;span style="color: blue"&gt;New &lt;/span&gt;XElement(MyNameSpace + &lt;span style="color: #a31515"&gt;"Countries"&lt;/span&gt;, _
                                                       &lt;span style="color: blue"&gt;From &lt;/span&gt;country &lt;span style="color: blue"&gt;In &lt;/span&gt;XDataSet _
                                                       &lt;span style="color: blue"&gt;Select New &lt;/span&gt;XElement(&lt;span style="color: #a31515"&gt;"Country"&lt;/span&gt;, _
                                                                            &lt;span style="color: blue"&gt;New &lt;/span&gt;XAttribute(&lt;span style="color: #a31515"&gt;"Code"&lt;/span&gt;, country.CountryISO), _
                                                                           &lt;span style="color: blue"&gt;New &lt;/span&gt;XAttribute(&lt;span style="color: #a31515"&gt;"Name"&lt;/span&gt;, country.CountryName))))

       &lt;span style="color: blue"&gt;Return &lt;/span&gt;XDoc.ToString
   &lt;span style="color: blue"&gt;End Function&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;But with Embedded Expressions and XML Literals we can make it even easier to write XML, but first what is embedded expressions, we have seen what XML literals is before and it is not very practical because we don't use XML in our program, but embedded expressions extend the user of XML Literals, embedded expressions are used to embedded values where required using &amp;lt;%= %&amp;gt; syntax. &lt;/p&gt;

&lt;p&gt;So the previous WebMethod can be re-written using XML Literals and Embedded Expressions, but first let us find out what we are trying to write, this is the format of the XML we want to construct. &lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: #6464b9"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;Countries &lt;/span&gt;&lt;span style="color: #b96464"&gt;xmlns&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;http://tempuri.org/Schema/Countries&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;Country &lt;/span&gt;&lt;span style="color: #b96464"&gt;Code&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"" &lt;/span&gt;&lt;span style="color: #b96464"&gt;Name&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;""&lt;/span&gt;&lt;span style="color: #6464b9"&gt;/&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #844646"&gt;Countries&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;So we can replace our previous Web Service using XML Literals and embedded expression using something like, &lt;/p&gt;

&lt;pre class="code"&gt;    &amp;lt;WebMethod()&amp;gt; _
    &lt;span style="color: blue"&gt;Public Function &lt;/span&gt;AllCountriesUsingXMLLiterals() &lt;span style="color: blue"&gt;As String

        Dim &lt;/span&gt;sud &lt;span style="color: blue"&gt;As New &lt;/span&gt;CountryDataSetTableAdapters.CountryTableTableAdapter

        &lt;span style="color: blue"&gt;Dim &lt;/span&gt;XDataSet &lt;span style="color: blue"&gt;As New &lt;/span&gt;CountryDataSet.CountryTableDataTable

        sud.Fill(XDataSet)

        &lt;span style="color: blue"&gt;Dim &lt;/span&gt;XDoc = _
            &lt;span style="color: #6464b9"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;Countries &lt;/span&gt;&lt;span style="color: #b96464"&gt;xmlns&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;http://tempuri.org/Schema/Countries&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                &lt;/span&gt;&lt;span style="background: #fffebf; color: #555555"&gt;&amp;lt;%=&lt;/span&gt; &lt;span style="color: blue"&gt;From &lt;/span&gt;country &lt;span style="color: blue"&gt;In &lt;/span&gt;XDataSet &lt;span style="color: blue"&gt;Select &lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;Country &lt;/span&gt;&lt;span style="color: #b96464"&gt;Code&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="background: #fffebf; color: #555555"&gt;&amp;lt;%=&lt;/span&gt; country.CountryISO &lt;span style="background: #fffebf; color: #555555"&gt;%&amp;gt;&lt;/span&gt; &lt;span style="color: #b96464"&gt;Name&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="background: #fffebf; color: #555555"&gt;&amp;lt;%=&lt;/span&gt; country.CountryName &lt;span style="background: #fffebf; color: #555555"&gt;%&amp;gt;&lt;/span&gt;&lt;span style="color: #6464b9"&gt;/&amp;gt; &lt;/span&gt;&lt;span style="background: #fffebf; color: #555555"&gt;%&amp;gt;
&lt;/span&gt;            &lt;span style="color: #6464b9"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #844646"&gt;Countries&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;

        &lt;/span&gt;&lt;span style="color: blue"&gt;Return &lt;/span&gt;XDoc.ToString
    &lt;span style="color: blue"&gt;End Function&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Thats it! Working with XML have never been so easy, and it can't get easier than this. Enjoy the good features of VB 9. More examples coming soon. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=120859"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=120859" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Silverlight2/aggbug/120859.aspx" width="1" height="1" /&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=tLZ5UhU_Ojk:-SAyfJm7pH4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=tLZ5UhU_Ojk:-SAyfJm7pH4:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=tLZ5UhU_Ojk:-SAyfJm7pH4:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?i=tLZ5UhU_Ojk:-SAyfJm7pH4:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/imranshaik/~4/tLZ5UhU_Ojk" height="1" width="1"/&gt;</description>
            <dc:creator>Imran Shaik</dc:creator>
            <guid isPermaLink="false">http://geekswithblogs.net/Silverlight2/archive/2008/03/30/xml-literals-and-embedded-expressions.aspx</guid>
            <pubDate>Sun, 30 Mar 2008 11:45:52 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Silverlight2/comments/120859.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Silverlight2/archive/2008/03/30/xml-literals-and-embedded-expressions.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Silverlight2/comments/commentRss/120859.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Silverlight2/services/trackbacks/120859.aspx</trackback:ping>
        <feedburner:origLink>http://geekswithblogs.net/Silverlight2/archive/2008/03/30/xml-literals-and-embedded-expressions.aspx</feedburner:origLink></item>
        <item>
            <title>Silverlight 2 Beta 1 - Web Services in &amp;quot;New School&amp;quot; approach.</title>
            <category>Silverlight</category>
            <link>http://feedproxy.google.com/~r/imranshaik/~3/-a9eQWcWnDg/silverlight-2-beta-1---web-services-in-quotnew-schoolquot.aspx</link>
            <description>&lt;p&gt;There might be a few samples of working with web services in Silverlight but I promise I'll keep you interested with VB.NET exclusive feature VB Literals. This is going to open a whole new way of looking and working with XML and Web Services.  &lt;/p&gt;  &lt;p&gt;*Note: Don't attempt to do everything I do in this tutorial in C# (espcially consuming WebService in Silverlight 2) because you simply can't, C# or any other language doesn't have this feature, so stick to VB.NET for consuming you can use C# for the rest, I'll warn when I am using VB.NET exclusive features, so if you want to convert this to C# you'll get enough warning. &lt;/p&gt;  &lt;p&gt;In this tutorial we'll look at &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Creating SQL Server 2005 Database &lt;/li&gt;    &lt;li&gt;Retrieving Data from Database in DataSet &lt;/li&gt;    &lt;li&gt;Consuming DataSet in ASMX WebService (using LINQ) &lt;/li&gt;    &lt;li&gt;Consuming WebService in Silverlight 2 (using VB Literals) &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Before you get started with this make sure you have installed&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Visual Studio 2008 &lt;/li&gt;    &lt;li&gt;SQL Express 2005 &lt;/li&gt;    &lt;li&gt;Silverlight 2 Beta 1 Tools for Visual Studio &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Before anything start with a Silverlight project, and make sure you select Web Solution for hosting, instead of HTML Test Page. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_014305_4.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="272" alt="2008-03-25_014305" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_014305_thumb_1.jpg" width="404" border="0" /&gt;&lt;/a&gt; &lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_014320_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="271" alt="2008-03-25_014320" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_014320_thumb.jpg" width="323" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h2&gt;Step 1 : Creating SQL Server 2005 Database &lt;/h2&gt;  &lt;p&gt;Now we'll create a SQL Server and add data in the database, for this example I have used countries example, so first go to the web project, select the "App_Data" folder and right-click and select "Add New Item..." &lt;/p&gt;  &lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_014611_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="74" alt="2008-03-25_014611" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_014611_thumb.jpg" width="208" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now Visual Studio will ask you the item you want, select "SQL Server Database", give a name to the database and then select select "Add", &lt;/p&gt;  &lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_014637_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="214" alt="2008-03-25_014637" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_014637_thumb.jpg" width="325" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This will add a new database to the Web Application, go to server explorer and select, and in Tables, select "Add New Table"&lt;/p&gt;  &lt;p&gt; &lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_014702_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="87" alt="2008-03-25_014702" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_014702_thumb.jpg" width="165" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now define the table, I have inserted only two columns for this example&lt;/p&gt;  &lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_014759_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="52" alt="2008-03-25_014759" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_014759_thumb.jpg" width="244" border="0" /&gt;&lt;/a&gt; &lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_014838_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="78" alt="2008-03-25_014838" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_014838_thumb.jpg" width="155" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now I have manually inserted rows in the table, &lt;/p&gt;  &lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_015552_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="244" alt="2008-03-25_015552" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_015552_thumb.jpg" width="102" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h2&gt;Step 2: Retrieving data from Database to DataSet.&lt;/h2&gt;  &lt;p&gt;Now go to the web site project and add new item, &lt;/p&gt;  &lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_015649_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="179" alt="2008-03-25_015649" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_015649_thumb.jpg" width="235" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;When the window pops up select "DataSet", select the file name I have used "CountryDataSet.xsd", Visual Studio will warn you that DataSet should go in "App_Code" Folder, select "Yes".&lt;/p&gt;  &lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_015709_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="307" alt="2008-03-25_015709" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_015709_thumb.jpg" width="469" border="0" /&gt;&lt;/a&gt; &lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_015725_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="170" alt="2008-03-25_015725" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_015725_thumb.jpg" width="411" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now you'll have an empty DataSet in the solution. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_015742_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="113" alt="2008-03-25_015742" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_015742_thumb.jpg" width="186" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Normally developers do this the "Old School" way, by setting the connections to the database, this way it will automatically make the connection string and generate datasets. &lt;/p&gt;  &lt;p&gt;Now the trick to get data in Dataset is the most simplest way to do it. &lt;/p&gt;  &lt;p&gt;Drag the table you want to add to DataSet space, if you have more than one table don't worry just drag all the tables you want in that dataset, if there are connections it will automatically set them all. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_015835_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="151" alt="2008-03-25_015835" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_015835_thumb.jpg" width="296" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;By default, the DataSet makes Fill,GetData table adapters, if you want to insert or update the tables you have to write new queries on the Table Adaptors. &lt;/p&gt;  &lt;p&gt;Now your data is ready to be consumed by the webservice. &lt;/p&gt;  &lt;h2&gt;Step 3: Consuming DataSet in ASMX web service (Using LINQ)&lt;/h2&gt;  &lt;p&gt;Again go to the Web Site Solution and select "Add New Item..." this time select "Web Service". &lt;/p&gt;  &lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_015913_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="308" alt="2008-03-25_015913" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_015913_thumb.jpg" width="467" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;By default, the application makes Hello World example, delete that and add a new function. &lt;/p&gt;  &lt;p&gt;But first, set the reference of the web service to "System.XML.Linq", Normally we use web services to communicate in XML format, but since Silverlight doesn't support "System.Data" it is not possible to return DataSet in XML format directly (if you attempt to return a DataSet directly Silverlight will throw errors when a reference is added) so we have to create our own XML String, so and we are going to use LINQ (Language Integrated Query) which is available in .NET Framework 3.0/3.5. &lt;/p&gt;  &lt;pre class="code"&gt;&amp;lt;WebMethod()&amp;gt; _
    &lt;span style="color: blue"&gt;Public Function &lt;/span&gt;AllCountries() &lt;span style="color: blue"&gt;As String

        Dim &lt;/span&gt;sud &lt;span style="color: blue"&gt;As New &lt;/span&gt;CountryDataSetTableAdapters.CountryTableTableAdapter

        &lt;span style="color: blue"&gt;Dim &lt;/span&gt;XDataSet &lt;span style="color: blue"&gt;As New &lt;/span&gt;CountryDataSet.CountryTableDataTable

        sud.Fill(XDataSet)

        &lt;span style="color: blue"&gt;Dim &lt;/span&gt;MyNameSpace &lt;span style="color: blue"&gt;As &lt;/span&gt;XNamespace = &lt;span style="color: #a31515"&gt;"http://tempuri.org/Schema/Countries/"

        &lt;/span&gt;&lt;span style="color: blue"&gt;Dim &lt;/span&gt;XDoc &lt;span style="color: blue"&gt;As &lt;/span&gt;XDocument = &lt;span style="color: blue"&gt;New &lt;/span&gt;XDocument(&lt;span style="color: blue"&gt;New &lt;/span&gt;XDeclaration(&lt;span style="color: #a31515"&gt;"1.0"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"utf-8"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"yes"&lt;/span&gt;), _
                                              &lt;span style="color: blue"&gt;New &lt;/span&gt;XElement(MyNameSpace + &lt;span style="color: #a31515"&gt;"Countries"&lt;/span&gt;, _
                                                        &lt;span style="color: blue"&gt;From &lt;/span&gt;country &lt;span style="color: blue"&gt;In &lt;/span&gt;XDataSet _
                                                        &lt;span style="color: blue"&gt;Select New &lt;/span&gt;XElement(&lt;span style="color: #a31515"&gt;"Country"&lt;/span&gt;, _
                                                                            &lt;span style="color: blue"&gt;New &lt;/span&gt;XAttribute(&lt;span style="color: #a31515"&gt;"Code"&lt;/span&gt;, country.CountryISO), _
                                                                            &lt;span style="color: blue"&gt;New &lt;/span&gt;XAttribute(&lt;span style="color: #a31515"&gt;"Name"&lt;/span&gt;, country.CountryName))))

        &lt;span style="color: blue"&gt;Return &lt;/span&gt;XDoc.ToString
    &lt;span style="color: blue"&gt;End Function&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;The Namespace is not required but it would be required to use VB literals when we are consuming this in Silverlight application. &lt;/p&gt;

&lt;h2&gt;Step 4: Consuming Web Service in Silverlight 2 (Using VB Literals) &lt;/h2&gt;

&lt;p&gt;Now we are finished with working on the web site project, and we will turn our focus on the Silverlight Project. &lt;/p&gt;

&lt;p&gt;First we'll add the "Web Reference" &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_022423_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="235" alt="2008-03-25_022423" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_022423_thumb.jpg" width="208" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Since the Web Services is in the same solution, you can just click "Discover" and it will fetch the web service, give a namespace to the web service to easily recognise within the application. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_022517_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="353" alt="2008-03-25_022517" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_022517_thumb.jpg" width="438" border="0" /&gt;&lt;/a&gt; &lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_022536_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="170" alt="2008-03-25_022536" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_022536_thumb.jpg" width="209" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;In Silverlight projects System.Xml.Linq is not automatically selected so you have to explicitly include it, right click on the Silverlight Project and then Select "Add Reference", and add reference to System.Xml.Linq, even after you have added reference you still have to import it in the managed code (VB imports System.Xml.Linq/ include System.Xml.Linq) &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_022642_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="291" alt="2008-03-25_022642" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_022642_thumb.jpg" width="345" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we have to call the web service from Managed code. &lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;Imports &lt;/span&gt;System.Xml.Linq
&lt;span style="color: #6464b9"&gt;
&lt;/span&gt;&lt;span style="color: blue"&gt;Partial Public Class &lt;/span&gt;Page
    &lt;span style="color: blue"&gt;Inherits &lt;/span&gt;UserControl

    &lt;span style="color: blue"&gt;Public Sub New&lt;/span&gt;()
        InitializeComponent()
    &lt;span style="color: blue"&gt;End Sub

    Private &lt;/span&gt;src &lt;span style="color: blue"&gt;As New &lt;/span&gt;CountryWebService.WebServiceSoapClient
    &lt;span style="color: blue"&gt;Private &lt;/span&gt;XMLData &lt;span style="color: blue"&gt;As New &lt;/span&gt;XDocument

    &lt;span style="color: blue"&gt;Private Sub &lt;/span&gt;Page_Loaded(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;sender &lt;span style="color: blue"&gt;As Object&lt;/span&gt;, &lt;span style="color: blue"&gt;ByVal &lt;/span&gt;e &lt;span style="color: blue"&gt;As &lt;/span&gt;System.Windows.RoutedEventArgs) &lt;span style="color: blue"&gt;Handles Me&lt;/span&gt;.Loaded

        src.AllCountriesAsync()
        &lt;span style="color: blue"&gt;AddHandler &lt;/span&gt;src.AllCountriesCompleted, &lt;span style="color: blue"&gt;AddressOf &lt;/span&gt;DownloadCompleted
    &lt;span style="color: blue"&gt;End Sub

    Private Sub &lt;/span&gt;DownloadCompleted(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;sender &lt;span style="color: blue"&gt;As Object&lt;/span&gt;, &lt;span style="color: blue"&gt;ByVal &lt;/span&gt;e &lt;span style="color: blue"&gt;As &lt;/span&gt;CountryWebService.AllCountriesCompletedEventArgs)

        XMLData = XDocument.Parse(e.Result)

    &lt;span style="color: blue"&gt;End Sub&lt;/span&gt;&lt;/pre&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;End Class
&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Now you can set a break point on XMLData = XDocument.Parse(e.Result)  and test the XML we are getting back.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_023106_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="463" alt="2008-03-25_023106" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_023106_thumb.jpg" width="454" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;As we have XML Data available, normally we create a class object, initialise properties are pick each attribute of the XMLData and populate its property, this is the only way to do in C# but for VB.NET there is very simple way.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;*WARNING: VB Exclusive feature below*&lt;/font&gt; &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In VB.NET we have an exclusive feature, called VB Literals, VB literals is a new feature in .NET framework 3.0, which makes life easy infact very easy, this is an extension of type infer available since early VB days, to use this option "Option Infer" should be set "On". &lt;/p&gt;

&lt;p&gt;You can google for "VB Literals" for more info, I won't go in details here so I'll just go directly to the point. &lt;/p&gt;

&lt;p&gt;Type infer means that we don't need to set the type while variable declaration, and this is an essential for VB Literals to work hence not included in C# or any other .NET languages. &lt;/p&gt;

&lt;p&gt;But for this example, since we are working on XML and to enable Intellisense we would require to get the schema of the XML we would be working on, this is not essential but without it there won't be any Intellisense. &lt;/p&gt;

&lt;p&gt;So first we'll get the schema for the XML we got back, to do this we'll set the breakpoint again and get the XML data from XMLData XDocument we are getting back from the webservice. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_023205_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="373" alt="2008-03-25_023205" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_023205_thumb.jpg" width="338" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Next we'll add a schema file by "Add New Item..." in the Silverlight project, there is a Template "XML to Schema" for this available on MSDN. The Name of the schema doesn't matter here, because we won't be looking at it ever, Visual Studio will do its own magic. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_023255_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="264" alt="2008-03-25_023255" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_023255_thumb.jpg" width="437" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Now since we already have the data copied in the clipboard, we'll select Add As XML and paste the copied XML to generate Schema. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_023307_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="310" alt="2008-03-25_023307" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_023307_thumb.jpg" width="392" border="0" /&gt;&lt;/a&gt; &lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_023326_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="187" alt="2008-03-25_023326" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_023326_thumb.jpg" width="206" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Now we have to import the schema by Adding the reference, Visual Studio will automatically recognises the namespace available in the project, all we have to do is provide the alias.  &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_023400_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="156" alt="2008-03-25_023400" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_023400_thumb.jpg" width="211" border="0" /&gt;&lt;/a&gt;   &lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_023415_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="95" alt="2008-03-25_023415" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_023415_thumb.jpg" width="392" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we are ready to do use VB Literals, simply declare a variable without any type declaration (Type Infer) &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_023606_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="125" alt="2008-03-25_023606" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_023606_thumb.jpg" width="637" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Visual Studio recognises the the data we are dealing with and started to help, without creating schema and importing we can still use VB Literals but there won't be any intellisense. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_023621_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="143" alt="2008-03-25_023621" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_023621_thumb.jpg" width="635" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Visual Studio recognises the Elements but don't know where you want to start digging the XML so its showing "?" But once you select the starting Element, it will know where you are and what you are dealing with so now it is showing the "Right Mark", it is its way of saying you are definitely dealing with this. the options are "@" for attribute, "&amp;lt;&amp;gt;" for any Child Element (NOTE: If you are using Element, then you should get its value e.g., i.&amp;lt;ElementName&lt;u&gt;&amp;gt;.Value&lt;/u&gt;) &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_023726_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="159" alt="2008-03-25_023726" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_023726_thumb.jpg" width="721" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;After you finish writing your query, something wonderful happens, if you add only one single element the Type Inference selects the data as IEnumerable(Of String) but if you add more than one to the collection it will automatically change to IEnumerable(Of &amp;lt;anonymous type&amp;gt;) &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_024200_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="62" alt="2008-03-25_024200" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_024200_thumb.jpg" width="516" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_024214_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="68" alt="2008-03-25_024214" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_024214_thumb.jpg" width="614" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;To consume this data in Silverlight application you can use them directly. &lt;/p&gt;

&lt;p&gt;In Page.xaml&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Grid &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Name&lt;/span&gt;&lt;span style="color: blue"&gt;="LayoutRoot" &lt;/span&gt;&lt;span style="color: red"&gt;Background&lt;/span&gt;&lt;span style="color: blue"&gt;="White"&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ListBox &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Name&lt;/span&gt;&lt;span style="color: blue"&gt;="CountryNames"/&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Grid&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;In Page.xaml.vb&lt;/p&gt;

&lt;pre class="code"&gt;CountryNames.ItemsSource = CountriesData&lt;/pre&gt;

&lt;p&gt;And when you run the application. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_024023_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="244" alt="2008-03-25_024023" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_024023_thumb.jpg" width="321" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;So the complete code looks something like, &lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_044631_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="465" alt="2008-03-25_044631" src="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/2008-03-25_044631_thumb.jpg" width="723" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;More on VB Literals and the wonders we can do in Silverlight coming soon. &lt;/p&gt;

&lt;div class="wlWriterSmartContent" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:fcec567e-0429-4a89-8e70-af2820877ff7" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;p&gt;Download Source &lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/Silverlight2/WindowsLiveWriter/Silverlight2Beta1WorkingwithWebService_1852/CountriesSample.zip" target="_blank"&gt;CountriesSample.ZIP (963 KB)&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=120739"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=120739" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Silverlight2/aggbug/120739.aspx" width="1" height="1" /&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=-a9eQWcWnDg:K6_KoeQVJig:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=-a9eQWcWnDg:K6_KoeQVJig:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/imranshaik?a=-a9eQWcWnDg:K6_KoeQVJig:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/imranshaik?i=-a9eQWcWnDg:K6_KoeQVJig:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/imranshaik/~4/-a9eQWcWnDg" height="1" width="1"/&gt;</description>
            <dc:creator>Imran Shaik</dc:creator>
            <guid isPermaLink="false">http://geekswithblogs.net/Silverlight2/archive/2008/03/25/silverlight-2-beta-1---web-services-in-quotnew-schoolquot.aspx</guid>
            <pubDate>Tue, 25 Mar 2008 10:17:04 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Silverlight2/comments/120739.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Silverlight2/archive/2008/03/25/silverlight-2-beta-1---web-services-in-quotnew-schoolquot.aspx#feedback</comments>
            <slash:comments>12</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/Silverlight2/comments/commentRss/120739.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Silverlight2/services/trackbacks/120739.aspx</trackback:ping>
        <feedburner:origLink>http://geekswithblogs.net/Silverlight2/archive/2008/03/25/silverlight-2-beta-1---web-services-in-quotnew-schoolquot.aspx</feedburner:origLink></item>
    </channel>
</rss>
