Windows 10 Insider Preview – Enabling Developer Mode

Windows-Dev

I installed Visual Studio Community Edition on the Windows 10 Insider Preview and got a pop-up message that told me that I needed to enable Developer Mode on my device.

The pop-up told me to go to the Settings to do this – but the option is not available there.

The solution is to open the Group Policy Editor and browse to:

Local Computer Policy, Administrative Templates, Windows Components, App Package Deployment

Select the Allows development of Windows Store apps and installing them from an integrated development environment (IDE) setting and set the state to Enabled.

win10-enable-dev-mode

Source: http://answers.microsoft.com/en-us/insider/forum/insider_wintp-insider_install/enable-developer-mode-for-windows-10/c85a90b0-056a-4e32-894e-d9e0dd2a54df

Windows Runtime – Special Characters in JSON (Parsed as HTML)

Windows-Dev

My app in progress uses a JSON data file that is parsed as HTML so that I can add bold and other useful HTML attributes to my data.

Until today, none of the special characters that I used within my bold tags presented any issues: *, ?, [ ], { }, !, >, >>

But, when I got the to the less than sign it was parsed as the opening of another HTML tag, and broke my lovely bold tags!

The solution was simple enough – simply encode the less than sign as I would in standard HTML, thus: <

So even though it works on WordPress, this is wrong:

<b><</b>

And this is right:

<b>&lt;</b>

Happy coding!

Windows Runtime – C# Send EMail from App

Windows-Dev

I’m working on my About page for a Windows Phone Runtime app and needed to be able to send an email for feedback or support issues.

Below is the code for my event handler in the code behind (AboutPage.cs):

        async private void Image_Email(object sender, TappedRoutedEventArgs e)
        {
            //Define email address to send to
            EmailRecipient sendTo = new EmailRecipient()
            {
                Address = "mail@domain.com"
            };

            //New email and define email subject
            EmailMessage mail = new EmailMessage();
            mail.Subject = "Linux Essentials - Feedback";

            //Add addressee to email
            mail.To.Add(sendTo);

            //Open share contact with email only
            await EmailManager.ShowComposeNewEmailAsync(mail);
        }

The XAML on my About page is simply an image with the Tapped event:

      <Image Source="Assets/Images/Mail.png"
             Height="64"
             Width="64"
             Margin="0,0,22,0"
             Tapped="Image_Email"/>

When defining a new email you can also specify the mail body text:

mail.Body = "this is the Body";

Source: http://dotnet.dzone.com/articles/how-send-mail-your-windows

Windows Runtime – C# Launch Hyperlink

Windows-Dev

I’m working on my About page for a Windows Phone Runtime app and needed to open a hyperlink in my code behind (AboutPage.cs).

Below is the code for my Tapped event handler:

        private void Image_Wordpress(object sender, TappedRoutedEventArgs e)
        {
            Launcher.LaunchUriAsync(new Uri("https://pricklytech.wordpress.com/"));
        }

The XAML on my About page is simply an image with the Tapped event:

      <Image Source="Assets/Images/Wordpress.png"
             Height="64"
             Width="64"
             Tapped="Image_Wordpress"/>

Source: http://stackoverflow.com/questions/12501174/opening-a-url-in-the-default-browser-in-a-windows-8-desktop-application

Windows Phone 8.1 Runtime – Forcing Light or Dark Theme

Windows8-Phone-Logo

In Windows Phone 8.1 Runtime apps we can set the theme for the app or for each page.

To set the them for the whole app add the highlighted code to App.xaml:

<Application
    x:Class="LinuxBasics.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:LinuxBasics"
    RequestedTheme="Dark">

For RequestedTheme you can choose light or dark. To set the theme per page use:

<Page x:Name="page"  RequestedTheme="Dark">

Sources: http://stackoverflow.com/questions/26478465/how-to-force-theme-in-windows-runtime-app

Windows Phone Dev – Disabling the Tilt Animation on a ListView

Windows8-Phone-Logo

I am working on a Windows Phone 8.1 Runtime app and have a ListView to display data on a detail page. The problem is that by default the tilt animation is enabled. This is not wanted because it gives visual feedback to the user that something should happen when the object is tapped.

To disable this behavior we need to create a copy of the default style of the ListView as follows:

Right click on the ListView in the designer and then select: Edit Additional Templates, Edit Generated Item Container (ItemContainerStyle), Edit a Copy…

A copy of the default style will be placed in your XAML.

Find the PointerUpThemeAnimation and PointerDownThemeAnimation Storyboards and remove them (or comment them out if you prefer):

<VisualStateGroup.Transitions>
     <VisualTransition From="Pressed"
                       To="Normal">
         <!--<Storyboard>
             <PointerUpThemeAnimation Storyboard.TargetName="TiltContainer" />
         </Storyboard>-->
       </VisualTransition>
     </VisualStateGroup.Transitions>
     <VisualState x:Name="Normal" />
     <VisualState x:Name="Pressed">
         <!--<Storyboard>
            <PointerDownThemeAnimation Storyboard.TargetName="TiltContainer" />
        </Storyboard>-->
     </VisualState>

Sources: http://www.visuallylocated.com/post/2014/07/09/Disabling-tilt-on-a-ListView-or-GridView.aspx