Windows 10 – Open Explorer to This PC

Windows-Dev

By default Windows 10 opens Explorer to the Quick access view. This view highlights Frequent folders and Recent files.

I much prefer the This PC view which shows Folders and Devices and drives.

This is how to make This PC the default view:

  • Open Explorer and click the View menu and then the Options button *
  • Set the Open File Explorer to drop down menu to This PC and then click Ok.

* If you click the lower half of the options button you will also need to click Change folder and search options.

This PC

Close and re-open Explorer.

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