Archive for December, 2010

Styles in Silverlight

We all are aware of CSS and user control concept in Asp.Net which is used for styling the webpage .In line with similar concept Silverlight provides option to use predefined look to  controls.While Styles used for applying simple make over to controls ,Templates are used for complex styling with a option to change complete visual representation.Generally Styles are used for a consistent look through out the application and control templates are used for visual improvement of controls.

In this post we will create a style and will attach to a control.

Defining A style

Styles are set common properties that can be reusable by various other instances.In Silverlight styles are defined in resource file can be applied to a control against its Style property. Read the rest of this entry »

Leave a comment

Passing Values Between Pages in Silverlight 4

Hi , In this post we will look into some of the approaches available for Passing Values between Silverlight pages SL To SL page and ASPX To SL page .Typical approach of legacy web system is Query String , where parameters are passed as Field –Value Pair.

Query String In Silverlight

In real application scenario suppose a Customer page when the User Clicks on Detail  of particular Customer.The customer id / Name will be used in query string and can be passed to the CustomerDetail page.The CustomerDetail page will parse the URL and fetch the details from data source based on the value from query string.

The Silverlight pages can access the query string from NavigationContext property of page (Check my earlier post for more detail ).So as of the above example the CustomerDetail page can access it with following one liner code ,this.NavigationContext.QueryString[“**QS Field Name**”]

  1. // Executes when the user navigates to this page.
  2. protected override void OnNavigatedTo(NavigationEventArgs e)
  3. {
  4. lblQSValue.Content = this.NavigationContext.QueryString[“PassQS”];
  5. }

Passing Parameters from Aspx Page to Silverlight by InitParameters

Although Query String is a way to pass the values between pages we can use alternate way of sending parameters to Silverlight application that is InitParam.

From Aspx page in Object Tag where the xap file is getting loaded we can add following tag.

  1. <param name=”InitParams” value=”PassVALA = IamA,PassVALB = 25″ />
  1. <body>
  2. <form id=”form1″ runat=”server” style=”height:100%”>
  3. <div id=”silverlightControlHost”>
  4. <object data=”data:application/x-silverlight-2,” type=”application/x-silverlight-2″ width=”100%” height=”100%”>
  5. <param name=”source” value=”ClientBin/NavigationSystem.xap”/>
  6. <param name=”onError” value=”onSilverlightError” />
  7. <param name=”background” value=”white” />
  8. <param name=”minRuntimeVersion” value=”4.0.50826.0″ />
  9. <param name=”InitParams” value=”PassVALA = IamA,PassVALB = 25″ />
  10. <param name=”autoUpgrade” value=”true” />
  11. <a href=”http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0&#8243; style=”text-decoration:none”>
  12. <img src=”http://go.microsoft.com/fwlink/?LinkId=161376&#8243; alt=”Get Microsoft Silverlight” style=”border-style:none”/>
  13. </a>
  14. </object><iframe id=”_sl_historyFrame” style=”visibility:hidden;height:0px;width:0px;border:0px”></iframe></div>
  15. </form>
  16. </body>

Now the same parameters can be accessed in the Silverlight application in Application_Startup event in App.xaml.

image

,

Leave a comment

Navigation Framework in Silverlight 4

Navigation is an important and one of the basic aspect of web application . In earlier versions of Silverlight Navigation system was missing, until  Silverlight 3 .This blog post is all about the concept of Navigation Framework and an attempt to summarize the overall concept .[Check Online Demo of this post].

Basic Concept

Frame
  • The concept of Navigation system revolves around Frame . Frame Control acts as a container for pages , it validate the state and maintain the navigation history.
  • A Frame can host one page at particular time.

Manas Patnaik Blog

  • Source : Source property of Frame defines the default page to load when the application initialized.
  • Navigate (URI uri) :Navigate Method navigates to the specific URI from code. Read the rest of this entry »

,

Leave a comment

Design a site like this with WordPress.com
Get started