//build/ Interesting sessions

Sessions about Windows Phone at //Build/ 2012

Day 1

Day 2

Day 3

Day 4

Open a link in IE application and send e-mail

In Windows Store apps Forums, some users asked a simple questions:

1. How to open a link in IE application?

  • Usando MVVM :
private async void GoTo()
           var uri = new Uri("http://www.saramgsilva.com/");
           await Windows.System.Launcher.LaunchUriAsync(uri);
  • Using directly an HyperlinkButton:
<HyperlinkButton  Click="OpenClick"  Tag="{Binding Link}"    Content="Read more.." />

   private void OpenClick(object sender, RoutedEventArgs e)

    var link = (HyperlinkButton) e.OriginalSource;

   Windows.System.Launcher.LaunchUriAsync(new Uri(link.Tag.ToString()));


2. How to allow to send an email?

 private async void MailTo()
           var uri = new Uri("mailto:myemail@live.com");
           await Windows.System.Launcher.LaunchUriAsync(uri);

Open and Close the charm [Windows 8 Store Apps]

In this articles Invoke charm programatically my tip was to show how to open the Settings Charm, Share Charm and Search Charm. And in this article i will expose a sample to open and close the charm.

In XAML i added to buttons, one to open the charm and another to close it:

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">

        <Button Content="Open" Click="ButtonOpenClick" Margin="48,281,0,449"/>
        <Button Content="Close" Click="ButtonCloseClick" Margin="49,346,0,384"/>

In code behind i do:

private void ButtonOpenClick(object sender, RoutedEventArgs e)

        private void ButtonCloseClick(object sender, RoutedEventArgs e)

Because the charm close each time it lost focus, my solution is to set the focus to the current page.