MainPage.xaml
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ExperimentTitle" Text="ExpNo:WAP1" TextAlignment="Right" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="ApplicationTitle" Text="WAP Programing" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="Basic HTML" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<phone:WebBrowser HorizontalAlignment="Left" Margin="10,73,0,0" Name="webBrowser1" VerticalAlignment="Top" Width="440" Height="528" />
<Button Content="Load HTML" Height="72" HorizontalAlignment="Left" Margin="-4,10,0,0" x:Name="btnLoadHTML" VerticalAlignment="Top" Width="200" FontSize="28" FontWeight="Bold" FontFamily="Calibri" Click="btnLoadHTML_Click" >
</Button>
</Grid>
</Grid>
|
ExpNo:WAP1(Experiment Title)
WAP Programing( Application Title)
Basic HTML (PageTitle)
Web Browser
Button(Load HTML)
|
MainPage.xaml.cs
using System;
using System.Windows;
using Microsoft.Phone.Controls;
using System.IO.IsolatedStorage;
using System.IO;
using System.Windows.Resources;
namespace Hello_Xhtml
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
}
// This Function is use to read the file from Isolated Storage
private void SaveHTMLFile()
{
string fileName = "First.htm";
IsolatedStorageFile isolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication();
if (isolatedStorageFile.FileExists(fileName) == true)
{
isolatedStorageFile.DeleteFile(fileName);
}
StreamResourceInfo streamResourceInfo = Application.GetResourceStream(new Uri(fileName, UriKind.Relative));
using (BinaryReader binaryReader = new BinaryReader(streamResourceInfo.Stream))
{byte[] data = binaryReader.ReadBytes((int)streamResourceInfo.Stream.Length);
using (BinaryWriter bw = new BinaryWriter(isolatedStorageFile.CreateFile(fileName)))
{ bw.Write(data);
bw.Close();
}
}
}
// Button Event handler
private void btnLoadHTML_Click(object sender, RoutedEventArgs e)
{ SaveHTMLFile();
webBrowser1.Navigate(new Uri("First.htm",UriKind.Relative));
}
}
}
|
Read and Write the File Through Isolated Storage.
Directly call the file through the Navigate Method. |