Saturday, 29 March 2014
Web view in windows app
. Open visual studio 13 > New project > Visual C# > Blank App
2. In solution explorer, open MainPage.Xaml and add some buttons (copy paste code below inside grid tag).
2. In solution explorer, open MainPage.Xaml and add some buttons (copy paste code below inside grid tag).
<StackPanel Margin="100">
<Button Click="Button_Click">Navigate to Url</Button>
<Button Click="Button_Click_1">Load local file</Button>
<Button Click="Button_Click_2">Read File as Web</Button>
<Button Click="Button_Click_3">Throw JavaScript based html on web page</Button>
<Button Click="Button_Click_4">Call JavaScript on page</Button>
<WebView DefaultBackgroundColor="White" Name="WebView1" Width="600" Height="400"></WebView>
</StackPanel>
3. Since we added 5 button we need to add 5 events too (1 for each button) respectively. you just goto each button event definition and enter the code inside braces or you can simply copy paste below code as it is under Main method closing braces.
private void Button_Click(object sender, RoutedEventArgs e)
{
WebView1.Navigate(new Uri("http://bing.com", UriKind.Absolute));
}
private async void Button_Click_1(object sender, RoutedEventArgs e)
{
StorageFile f = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///html/example.html"));
string htmlFragment = await FileIO.ReadTextAsync(f);
WebView1.NavigateToString(htmlFragment);
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
string url = "ms-appx-web:///html/example.html";
WebView1.Navigate(new Uri(url));
}
private void Button_Click_3(object sender, RoutedEventArgs e)
{
string htmlFragment = @"
<html>
<head>
<script type='text/javascript'>
function doSomething()
{
document.getElementById('myDiv').innerText = 'GoodBye';
return 'Hello World!';
}
</script>
</head>
<body>
<div id='myDiv'>Hello</div>
</body>
</html>";
WebView1.NavigateToString(htmlFragment);
}
private async void Button_Click_4(object sender, RoutedEventArgs e)
{
string s = await WebView1.InvokeScriptAsync("doSomething", null);
MessageDialog dailog = new MessageDialog(s);
dailog.ShowAsync();
}
Implementing live tiles on windows
Lets do it now!
1. Open visual studio 13 > New project > Visual C# > Blank App
2. In solution explorer, open MainPage.Xaml and add a button.
3. Add below lines of code to button event(right clicking button code and select view definition) in csharp file.
3. Add below lines of code to button event(right clicking button code and select view definition) in csharp file.
string tileXmlString = " <tile >"
+ " <visual version='2' >"
+ " <binding template='TileSquare150x150Image' fallback='TileSquareImage' >"
+ " <image id='1' src='ms-appx:///images/graySquare150x150.png' alt='Gray image'/ >"
+ " </binding >"
+ " <binding template='TileWide310x150ImageAndText01' fallback='TileWideImageAndText01' >"
+ " <image id='1' src='ms-appx:///images/New Tile.png' alt='Green'/ >"
+ " <text id='1' >Microsoft Innovation Center </text >"
+ " </binding >"
+ " <binding template='TileSquare310x310Image' >"
+ " <image id='1' src='ms-appx:///images/purpleSquare310x310.png' alt='Purple image'/ >"
+ " </binding >"
+ " </visual >"
+ " </tile >";
// Create a DOM.
Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();
// Load the xml string into the DOM.
tileDOM.LoadXml(tileXmlString);
// Create a tile notification.
TileNotification tile = new TileNotification(tileDOM);
// Send the notification to the application’s tile.
TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);
Friday, 28 March 2014
Monday, 24 March 2014
Friday, 21 March 2014
Wednesday, 19 March 2014
Saturday, 15 March 2014
Friday, 14 March 2014
Link for adding PYF flyout in APP for code for better Pakistan
https://drive.google.com/file/d/0Bx_unVLBwnaNeUN6Q1p1d1V5WFU/edit?usp=sharing
Tuesday, 11 March 2014
Monday, 10 March 2014
ASP.NET MVC
http://channel9.msdn.com/Shows/Web+Camps+TV/Introducing-the-newest-dots-in-ASP-NET-with-Daniel-Roth
Visual Studio 2013 Web Editor Features - HTML5
http://channel9.msdn.com/Blogs/ASP-NET-Site-Videos/Visual-Studio-2013-Web-Editor-Features-HTML5
Subscribe to:
Comments (Atom)













