vendredi 1 mars 2019

XAMARIN Tizen for Tvs and .NET Standard 2.0 [2019][XAML, C#]

My return of Experience on XAMARIN for TIZEN TVs the 1st of March 2019

Here is documentation where you can find about Xamarin Forms for Tizen:

Having reseted my laptop since last time I had used Xamarin Tizen I needed to go through the all the different steps to re install Tizen, you can find the full steps here:

TIP: took me 10 minutes to figure out why I could not create an emulator image , make sure that in your package manager you install the Tizen 4 TV emulator and the Tizen SDK tools. Under Extensions SDK make sure you also select TV extensions, the download of all of the SDK and emulators can take up quite a long time so in the mean time I had recommended that you head over to Microsoft Docs for Tizen for some light reading =).

My Findings:

Last year when I used the Preview of Xamarin for Tizen here where my initial findings, you had the sensation that the SDK was not fully finish (being a preview that seemed normal), the emulator was very buggy and often crashed, the debugger did not work (unable to set a break point).

Framework versions:

  • Tizen.NET (
  • Tizen.NET.Sdk (1.0.1)
  • Xamarin.Forms(

The application that I built is on one page for now, it receives and formats my data into a a list that contains a list. It will populate a ListView, this first ListView data template will hold another ListView so that we can show data horizontally (imagine the Netflix application).

Universal Windows Platform (UWP) 

When creating this application I first started by the UWP as I thought it would be quicker,  the first issue that I was that the debugger did not want to stop on my break points I had the follow error:

"The breakpoint will not currently be hit. No symbols have been loaded for this document"

which is not practical (at all!).

To fix this issue I removed all of the bin and obj folders in my UWP app and removed this options
Debug=>Options=>General => Remove the check mark for "Enable Just My Code"
and it did the trick for me.

Here is what it looks like on the UWP app:

Not pretty but it gets the job done.

Next on Tizen for TV

For the Tizen, application the debugger is still "weak", it will break on you often unfortunately, another issue I found was that I was not not able to move the debug back when it hit a break point.

After a sometime even Visual Studio was telling me that something was wrong:

To be fair it was not all doom and gloom because the debugger did work sometimes:

And you could go inside the properties and investigate, this is a great improvement over the last time I tested this platform. On other issue that I found was that the debugger did not resurface errors, even when explicitly crating an error it never surfaced it.

When launching the app in the Tizen Emulator it can take a few seconds for everything to lunch.

Here is what the same app looks like in the Tizen emulator:

 It would seem that some of the binding elements are not 100% finished, none of the images will load. Also navigating inside the app is very very slow, from what I am seeing you might better off buying a Samsung TV to debug then using the emulator!

All in all here are a summary of my findings:

  1. Tizen 5 Tv SDK is working much better then the Tizen 4 Tv Sdk
  2. Te emulator really works this time (last year I needed hacks to get it working), however only the version 5 worked for me and not the version 4, also you must arm yourself with patience for the app to load.  Everything is very lagy in the emulator.
  3. the debugger from Visual Studio is now working"ish", it can crash your Visual Studio but at least this time around you cant setup break points in your code.
  4. Binding still seems to be an issue, maybe this is a Xamarin issue ill have to investigate

lundi 14 janvier 2019

[how to] Using Multilingual App Toolkit to translate your UWP application

In this post we are going to see who easy it is to make your application multilingual using Microsoft Multilingual App Toolkit to translate your UWP application.

First you need a class that will allow us to get the translated string by using the ResourceLoader property.

 public class MyLocalizedClass
        private static ResourceLoader _localizedResources;

        public ResourceLoader LocalizedResources
                if (_localizedResources == null)
                    _localizedResources = new ResourceLoader();

                return _localizedResources;

        public string this[string key]
                if (_localizedResources == null)
                    _localizedResources = new ResourceLoader();

                return _localizedResources.GetString(key);

You will need to bind all of the text in your application to your resource file, you can do this as follow:

                    Style="{StaticResource TitleTextBlockStyle}"
                    Text="{Binding Path=[MyApplicationHeader], Source={StaticResource LocalizedStrings}, FallbackValue='MyApplicationHeader'}"                    TextWrapping="NoWrap" />

My MyApplicationHeader key will need to be added in resources.resw with a value as follows:

Next we will need to structure our application to with a folder string at the root of the app, this folder will also need to add a folder en and then add a resource file that we will call: Resources.resw

It should look as follows:

Next you will need to install Multilingual App Toolkit v4.0 (VS 2017), which you can find here. Once installed in Visual Studio under Tools your should see Multilingual App Toolkit:

you will need to Enable selection in the Multilingual App Toolkit.

Next you are going to need to install the Multilingual App Toolkit 4.0 Editor.

Now we are going to add translation languages to the application, again make sure you have enable Multilingual App Toolkit in your UWP application next click on the project, select Multilingual App Toolkit and click on Add translation as follows:

I will add french:

A new folder should be created inside you Strings folder:

We are going to right click on the project and use automatic translate from English to French using machine translations:

If you select Generate machine translations and you have errors most likely the issue is that you don't have the correct credentials to use Cognitive Services, you can fix this by reading this.

Once you have fixed your credential issues or if you don't have any issues you should see that the resources file under fr has been updated with french translated strings:

Now to test this new language you can force your application in French by overriding the application language as follows:

 Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "fr"

Happy coding!

dimanche 9 décembre 2018

Using WinAppDriver to do UI Test Automation on your Windows Application, using the My Radio UWP - Part I

Because test is caring you should always try to test as much as possible your application to make sure that is it running smoothly.

We are going to setup multiples UI tests paths that need to be passed before a new version of the application can be pushed to the store. This will allows us to make sure that our application passes all of the basic quality checks and that all classic user paths are still functional.

We are going to have a deep look into one of these test path so that you too can improve your app by using UI test automation. 


First I highly recommend to have a look at the github repository on how WinAppDriver can be used:

Installing and Running Windows Application Driver

  1. Download Windows Application Driver installer from
  2. Run the installer on a Windows 10 machine where your application under test is installed and will be tested
  3. Run WinAppDriver.exe from the installation directory (E.g. C:\Program Files (x86)\Windows Application Driver)
Windows Application Driver will then be running on the test machine listening to requests on the default IP address and port ( You should have something as follows:

Locating Elements

The latest Visual Studio version by default includes the Windows SDK with a great tool to inspect the application you are testing. This tool allows you to see every UI element/node that you can query using Windows Application Driver
This inspect.exe tool can be found under the Windows SDK folder which is typically C:\Program Files (x86)\Windows Kits\10\bin\

Once you have launched the tool you should have a window as follows:

Here we can see that I have already launch the My Radio application.

We are going to be looking at 3 users Paths:

  • Arrive on Home, check we are on Home, click on favorite check we are on favorite and then go back to home
  • Can we will click on a radio thumbnail and make sure that it is playing
  • Advanced test : In another post we will go over how to create a more complex test in which we will:  We click on discovery, click on a category, click on a radio add it to our favorites, go to favorites and check that it is there.

Can I click on a button

First to be able to have the inspect tool select and highlight your selected item you must have activated these two buttons which are called watch cursor and show highlighted rectangle.

Now we are going to select the item that we wish to click on.  In my application the XAML code for this home button is:

                <NavigationViewItem x:Name="MainView" Tag="MainView">
                    <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
                            Symbol="Home" />
                            Text="Home" />

Here is what it looks like in the inspect tool:

We can see that the automation id is "MainView" and when we look on the favorite button we can see that its id is "FavoriteView" for our first test we are going to be using FindElementByName to check and see if we have a specific text in the visible view and FindElementByAccessibilityId to look for a UIElement that has this specific Id.

Here is the TestMethod:

 public void IsSideNavigationWorking()
            //We arrive on home            
            var homeText = session.FindElementByName("Explore Radios");

            //check to see if we see the explore radios text

            //click on categorie

            //check to see if we see the fav radios text
            var favText = session.FindElementByName("My Favorite Radios");
            //go back on home view
            var homeTextV2 = session.FindElementByName("Explore Radios");

            //check to see if we are on correct view

Is Radio playing user path

Here is the user path we are going to check:

  • launch the application
  • click on home and check that home is selected
  • click on first radio thumbnail and check that the radio is playing.
    • to check that radio is playing we are going to look for the media element that plays the radio item
Here is the inspect tool on the first radio in our list.

And here is the full test:

Here you have it, we have gone over two easy example on how to use WinAppDriver to do our UI Test Automation on a UWP Application. In the next Article we will do a deepdive on how to use WinAppDriver.

lundi 27 août 2018

[UWP/XAML] How to customize your NavigationView and add NavigationViewItem next to the Settings button

In this tutorial we are going to see how to add NavigationViewItems next to your Settings button in your NavigationView view.

First we need to get the Template of the NavigationView, Document Outline => Your NavigationView => Edit Template => edit a Copy.

Here is mine:

Look for the style that has a target type = Navigation View, here is mine:

 <Style x:Key="NavigationViewStyle1" TargetType="NavigationView">

Next we will need to find the NavigationViewItem that holds our settings button:

<NavigationViewItem x:Name="SettingsNavPaneItem" Grid.Row="7">
                      <SymbolIcon Symbol="Setting" />

Now we are going to add our 2 new buttons, first we are going to add s stackpanel and move the property Grid.Row=7 to it as follows:

<StackPanel Grid.Row="7">
   <NavigationViewItem x:Name="AddedNavItemOne"    Tag="MyViewOne">
   <SymbolIcon Symbol="World" />
</NavigationViewItem> <NavigationViewItem x:Name="AddedNavItemTwo" Tag="MyViewTwo">
   <SymbolIcon Symbol="Search" />
</NavigationViewItem> <NavigationViewItem x:Name="SettingsNavPaneItem"> <NavigationViewItem.Icon> <SymbolIcon Symbol="Setting" /> </NavigationViewItem.Icon> </NavigationViewItem> </StackPanel>

Now we need to be able to handle the Click actions of these 2 new NavigationViewItem.

We are going to create a class that inherits from NavigationView that will be called ExtendedNavigationView and we arer going to look for our 2 buttons and set handlers on the Tapped events as follows:

_navItemOne= GetTemplateChild("AddedNavItemOne") as NavigationViewItem;
//addign events
_navItemOne.Tapped += NavItem_Tapped;

The full class will look as follows:

 public class ExtendedNavigationView : NavigationView
        private NavigationViewItem _navItemOne;
        private NavigationViewItem _navItemTwo;

        protected override void OnApplyTemplate()


        private void SetupExtraNavItems()
            //check to see if not already set
            if (_navItemOne!= null)
                //unload events
                _navItemOne.Tapped -= NavItem_Tapped;

            if (_navItemTwo!= null)
                _navItemTwo.Tapped -= NavItem_Tapped;

            _navItemOne= GetTemplateChild("AddedNavItemOne") as NavigationViewItem;
            _navItemTwo = GetTemplateChild("AddedNavItemTwo") as NavigationViewItem;           

            if (_navItemOne== null || _navItemTwo== null)

            //addign events
            _navItemOne.Tapped += NavItem_Tapped;
            _navItemTwo.Tapped += NavItem_Tapped;            

        private void NavItem_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
            var NavView = (sender as NavigationViewItem).Tag;
            //navigate to item

And there you have it you have customized your NavigationView with 2 new NavigationViewItems above the Settings button.

Happy Coding.

mercredi 1 août 2018

[UWP/XAML] using Microsoft.Toolkit for Implicit animations using ScalarAnimation, OpacityAnimation, TranslationAnimation

Do you hate having to use Compositor?

_compositor = new Compositor();
_root = ElementCompositionPreview.GetElementVisual(RootGrid);

Well Microsoft.Toolkit.Uwp.UI.Animations is here to save you (and me).  The toolkit has added implicit animation which will allow you to easily add animations to your elements.  You wont need to use Storyboard animation!

In this example we are going to see how to:

  •  Add a translation to an element
  • Show and hide an element using Opacity
  • Scale an element
The advantage of using an Implicit animation is that it can for example be execute when you change the visibility of a component using:



To move an element in your app using implicit animation you have 2 options either you use ScalarAnimation or TranslationAnimation.


Has 3 main properties that you are going to want to set:
  • From
  • To
  • Duration
From and To are based on the x-y-z axis
Duration uses a h:m:s format

                    Duration="0:0:1" />

This means we are going to add 500 to the x position, 300 to the y postion and 0 to the z. The To=0 will take the element from its current position and the translation will take 1 second.


Same as the translation this also takes 3 properties, however the From and To only takes one value as the opacity property is only based on one value.

                    Duration="0:0:2" />


If you wish to have more control on your animation you can also use ScalarAnimation which will allow you to more precisely (I find) to set the values to the property you wish to change.


First you need to set your Target, which is the property you are going to want to change.  Then depending on your target like the other animations you will set the From, To, Duration

Combining Animations

Now we are going to combine 2 animations using the ShowAnimations and HideAnimations.  We will use ScalarAnimation and OpacityAnimation to move and change the opacity of our object.

Here is the full XAML:

 <Button Click="Button_Click" Content="Hit me" />
                    Duration="0:0:1" />-->

                    Duration="0:0:2" />

                    Duration="0:0:2" />


                    Duration="0:0:1" />-->

C# Code:

private void Button_Click(object sender, RoutedEventArgs e)
            if (MyRec != null)
                MyRec.Visibility = MyRec.Visibility == Visibility.Collapsed ? Visibility.Visible : Visibility.Collapsed;

Happy Coding.

lundi 25 juin 2018

UWP/XAML using PopupThemeTransition / PopOutThemeAnimation / PopInThemeAnimation to animate elements coming in and out of your app [Part 1]

In UWP we have this great control called Popup this control can allow you to quickly and cleanly have element pop in and pop out of your view. Also we will look at how to do more of less the same thing with only a Grid.

In this post I wont go into details about the popup control itselft however if you are interested in getting more information msdn is the best place to look.

First we are going to create our simple popup element, make sure that you set the IsOpen property to false (this will hide your popup),  IsLightDismissEnabled to true will mean that if the user clicks outside of the popup it will disappear.

Here is what the XAML can look like:


To add transition to when the popup will be shown we will add ChildTransitions:

           <PopupThemeTransition FromVerticalOffset="100" />

This will add an animation, the popup will come from the bottom with a translation of 100px. If you have wanted a Horizontal translation then you could have used FromHorizontalOffset.

For this popup to be displayed all you need is to set the IsOpen to true :

 PopupFromBottom.IsOpen = true;

Now if we wanted the popup to hide it self after 3 seconds all we would need to add is a wait of 3 seconds and again change the IsOpen to false as follows:

PopupFromBottom.IsOpen = true;

//wait 3 sec
await Task.Delay(TimeSpan.FromSeconds(3));

PopupFromBottom.IsOpen = false;

In the previous example we used the default popup control which allowed us to use the lightdismiss and directly attach the PopupThemeTransition animations to the popup.  However we always have custome cases where we need custome code and sometimes the default controls just wont cut it.  NOw we are going to see how to use a Grid as a popup.

first we are going to create our Grid as follows:

            Opacity="0" />

Next we are going to add storyboards and use PopInThemeAnimation and PopOutThemeAnimation
to pop in and pop out our grid.  Here is the Storyboard XAML code:

 <Storyboard x:Name="PopOutStoryboard">
            <PopOutThemeAnimation SpeedRatio="2" TargetName="GridPopup" />
 <Storyboard x:Name="PopInStoryboard">
                TargetName="GridPopup" />
                Duration="0" />

and now to easily call this code all we need to do:

        private void OpenStoryboard_Click(object sender, RoutedEventArgs e)

        private void CloseStoryboard_Click(object sender, RoutedEventArgs e)

And there you are! You can find the full code here.

jeudi 22 mars 2018

UWP, C# - Retrieve the redirect url using HttpClient from the Headers of the Response - [HttpClient,C#]

I wanted to share this little piece of code because I did not quickly find any great documentation on this.

My needs where as follows: I had a URL lets say and I did not have the direct access to the image of the URL.  So I ended up creating a small static class that holds a method GetRedirectedUrl that will get my redirect url.

Here is my code:

public static class CoreTools
       public static async Task<string> GetRedirectedUrl(string url)
            //this allows you to set the settings so that we can get the redirect url
            var handler = new HttpClientHandler()
                AllowAutoRedirect = false
            string redirectedUrl = null;

            using (HttpClient client = new HttpClient(handler))
            using (HttpResponseMessage response = await client.GetAsync(url))
            using (HttpContent content = response.Content)
                // ... Read the StatusCode in the response 
                // to see if we have the redirected url
                if (response.StatusCode == System.Net.HttpStatusCode.Found)
                    HttpResponseHeaders headers = response.Headers;
                    // do we have headers 
                    //do we have something in location
if (headers != null && headers.Location != null) { redirectedUrl = headers.Location.AbsoluteUri; } } } return redirectedUrl; } }

You can find my gist here.
Happy Coding