(X) Hide this
    • Login
    • Join
      • Generate New Image
        By clicking 'Register' you accept the terms of use .

Tip: How to use static resources?

(0 votes)
Denislav Savkov
>
Denislav Savkov
Joined Feb 11, 2008
Articles:   14
Comments:   6
More Articles
2 comments   /   posted on Sep 02, 2008
Tags:   static-resources , denislav-savkov
Categories:   General

Static resources are declared in Silverlight with the only idea to be reused from multiple places in your code. For example, when you declare a style as a static resource on application level, then this style can be referenced and applied to any control in that application. The syntax when you reference a declared static resource is as follows: {StaticResource resourceName} - where resourceName should be replaced with the name of the declared resource. See the example below:

Xaml

 <Button Style="{StaticResource simpleStyle}" x:Name="pushMeButton" Cursor="Hand"></Button>

As you can see the Button's Style property is set to be equal to {StaticResource simpleStyle}. Thus runtime the appropriate style will be taken from the current control's or application's resources and applied to that button. You do not have to specify where the resource should be taken from: whether from the application or from the user control resources.

That's it!


Subscribe

Comments

  • -_-

    RE: How to use static resources?


    posted by Parag Mehta on Sep 02, 2008 21:17

    Why do you guys are posting useless posts ? You made 3 posts for useless and pretty basic things, just don't post for the sake of posting.

  • iiordanov

    RE: How to use static resources?


    posted by iiordanov on Sep 02, 2008 23:48

    Hi Parag,

    I hope you have noticed that this is the Tips section of the site. When it comes about tips there is no useless tip, right? Whether one tip is useful or not depends ONLY on the level of experiance of the visitor. Silverlight is a new technology and this site is made to serve not only the advanced users but also the ones that ask themselfs very basic questions such as 'How to use static resources'. If you find one tip to be very basic, then just skip it, I am pretty sure that you will find others that will be useful also to you. We are adding constantly new tips...

    Best Regards
    Ilia Iordanov

    SilverlightShow

Add Comment

Login to comment:
  *      *