Sunday, October 23, 2011

Silverlight Resources & XML

The Silverlight application is actually a package of files archived using ZIP and stored as a single file with the .xap extension. This file can include resources we want to be available for our application. We can alternatively keep these resources on the server or have them as part of the DLL file, which is the default behavior.
The following code sample includes an XML resource file packed as part of the DLL file. This code sample shows how simple it is to access that XML resource and how simple it is to parser its data using Linq to XML.

The following is the XML file (lib.xml). We save it within the root directory of our Silverlight application.

<?xml version="1.0" encoding="utf-8" ?>
    <title>Core Silverlight</title>
    <author>Jonathan Taylor</author>
    <title>Core Python</title>
    <author>Greg Johnston</author>
    <title>F# Professional</title>
    <author>Nathan Shultz</author>
The following is the XAML file that defines the user interface (MainPage.xaml).
<UserControl x:Class="SilverlightApplication21.MainPage"
    d:DesignHeight="300" d:DesignWidth="800">

    <Grid x:Name="LayoutRoot" Background="White">
        <Button Content="Press Here" Height="23"
                HorizontalAlignment="Left" Margin="53,39,0,0"
                Name="PressHereButton" VerticalAlignment="Top"
                Width="75" Click="PressHereButtonClick" />

Read more: Life Michael
QR: silverlight-resources-amp-xml.aspx

Posted via email from Jasper-Net