Life with Visio and other Microsoft Toys!

Posts Tagged ‘C#

Stand up and be counted.

leave a comment »

Last Year I joined a number of the Canadian MVPs for a day of NDA, skill improvement and general interactions.

For most of the sessions, the key word was caNaDA, so the only thing I can say about those sessions is the Microsoft has some interesting announcements coming up in the near future. Of course, some of the skill building sessions were not and I can talk about them.

There were several sessions on how to make presentations, from preparing to presenting. Unfortunately, there were a number of death by PowerPoint comments. PowerPoint is a tool and as such, the power of that tool is in the hands of the presenter. Only a poor workman blames their tools. PowerPoint has a lot of power and can greatly enhance a presentation, but you need to learn it properly and practice with it. It is not a crutch, so do not overload it with information. Keep it simple. The slides have a notes feature for highlighting points about the slide, possibly question that the slide may invoke.  Audience tend to ask if the slides will be published. So a little extra in the slides would be appreciated.


John Marshall… Visio MVP


Written by johnvisiomvp

March 27, 2017 at 6:36 pm

UWP Samples generate hundred of errors?

with one comment

For the past few months I have had problems trying to run any of the Windows 10 UWP samples. Each attempt resulted in hundreds of errors.  Yesterday, thanks to Colin Melia and a little Google spelunking I may have found the issue and the solution.

The Googling turned up which indicates the same issues and that the problem may be with one of the references, Microsoft.NetCore.UniversalWindowsPlatform. Since I have been having issues, I did a clean install and installed the Windows 10 SDK. The issue appears to be that the samples were created with the 5.0 version of that file, but the clean install used 5.1. So when trying to open the samples, the reference could not resolve.

The solution was to open the project, in the Solution Explorer, right click reference and chose Manage NuGet Packages… Select Microsoft.NetCore.UniversalWindowsPlatform and select Update. I was able to do a Clean Project and Run.

No more errors!

Hopefully this will work for others.

Remember, if your solution contains more than one project, you probably will have to do this for each project.


John Marshall… Visio MVP

Written by johnvisiomvp

April 17, 2016 at 4:21 pm

Universal Apps – Multilingual Toolkit

leave a comment »

I fell in love with the Multilingual Toolkit when it was first introduced and found it very useful to add multiple languages to my apps. The only down side was that the submission process increased with each language. Even so, the Toolkit was useful in translating the text that is submitted with the app. All I had to do was add extra strings to the project, have them translations and then use the translations in the submission.

The XLF files use an industry standard for translators, so it is a very useful way to communicate with translators. The translator may have his own application for handling the XLF file, but the Toolkit does come with a useful app that anyone can use to do the translation. Unfortunately, the first release seemed to indicate that you had to install Visual Studio, the current version still seems to be a part of Visual Studio.

Of course, that familiarity caused problems. When you add languages in WP7 or WP8, the toolkit would automatically add the resource file (resx) and the XLF file for that language. With 8.1, only the XLF file is added. Of course, correcting that mistake is a mistake, only the resource file for the default language is needed. If you add the missing resource files, you will get a cryptic error message about duplication.

Rather than AppResources.resx, 8.1 uses resw files and the name is string/EN/Resources.resw. Converting from resx to resw is just a matter of renaming the extension, but I prefer to just copy all the strings and paste. I have yet to try it, but it should be possible to add the language to the filename as was done in WP7 / WP8.

With 8.1 the C# code for using strings from the resource file is to add

var loader = new Windows.ApplicationModel.Resources.ResourceLoader();

ErrorBlock.Text = loader.GetString(“ErrorCode01”)

In the xaml it is a matter of


to the textblock or button. This will overwrite the content of the Text or Content parameter, but they should be left in for editing. I tend to add an x to the end of the test. Unlike in WP7 and WP8, Visual Studio does not show the resource string in the editor. So the overwritten string are useful for determining the look and feel while editing.

Also  there is no XML that shows the languages being used, so the task of removing a language is just a matter of deleting the appropriate XLF file.

Another interesting thing is that the UIC can change several attributes. So for one use of a UIC, you can change the text and the width for a textblock. In the resource file it would be Help.Text and Help.Width.


John Marshall… Visio MVP

Universal Apps – Navigation

leave a comment »

Unlike the navigation on Windows Phone 7, the navigation is a bit more complex in a Universal App, but luckily, Microsoft has provided some helpers. To add the helpers, you need to create the page with a Basic rather than a Blank page. You will be told that you are missing components and do you want to add them. Accept and the navigation components will be added. One key point that MVP Andy Wigley mentioned in an MVA course on Building Apps for Windows Phone 8.1 JumpStart is that the Blank default MainPage is created with a Blank page rather than a Blank Page. So you need to delete the MainPage and create a new one from a Basic page.

For some reason, I used cut & paste to merge a WP7 project into a UA project and somehow lost the name of the page (It should be pageRoot). Trying to work out what went wrong was not easy. For the most part, the process seemed easy. Create a skeleton app with the name you want, delete MainPage and replace with a new one based on Basic page and cut and paste the code. Ignore the declaration section of the old cold and just copy over the content of the Grid.

The NavigationService.Navigate are replaced with Frame.Navigate(typeof(NextPage));

Most of the code in the cs files are placed in classes using the same name in the Project.Shared folder. So there should be a MainPage.xaml.cs in that folder when you are done. The code in the xaml files will be in the Windows and duplicated in the Phone folders. This is where most of the differences of the Windows and Phone versions of the app will appear.

Andy Wigley’s JumpStart course on MVA is a good start.

Next time languages.


John Marshall… Visio MVP

Written by johnvisiomvp

June 7, 2014 at 4:54 pm

WP7 Multilingual AppBar.

with one comment

The current phone app I am working on is based around a pivot and to get the most out of the pivot I want to use a different appbar for each pivot item. Luckily, Microsoft has a good article on how to do it.

How to use different app bars in a single Pivot control for Windows Phone

Unfortunately, the article has a few problems. The main ones deal with a need to know. This is a pivot and this article suggests placing the appbar in App.xaml. This is a pivot and only the page with the pivot needs to know about it or cares. This also means the background code will be in App.xaml.cs which complicates things. Since most of my apps have been multilingual, the solution did not handle the binding required for the resource file.

So the solution was to take the idea and move it to the page that had the pivot. This meant changing the xaml code from using Application.Resource to phone:PhoneApplicationPage.Resources and use throwaway values for the text. The SelectionChanged method of the pivot would take care of adding the correct text. Since I like to have optional menu items and there is no way to hide menu items, I left that up to the code behind and removed any references to the appbar menu from the xaml code. The resulting SelectionChanged method looked like.

private void Pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
switch (((Pivot)sender).SelectedIndex)
case 1:
ApplicationBar = ((ApplicationBar)Resources["AppBar1"]);
((ApplicationBarIconButton)ApplicationBar.Buttons[0]).Text = AppResources.AppBar1a;
((ApplicationBarIconButton)ApplicationBar.Buttons[1]).Text = AppResources.AppBar1b;
((ApplicationBarIconButton)ApplicationBar.Buttons[2]).Text = AppResources.AppBar1c;
((ApplicationBarIconButton)ApplicationBar.Buttons[3]).Text = AppResources.AppBar1d;
case 2:
ApplicationBar = ((ApplicationBar)Resources["AppBar2"]);
((ApplicationBarIconButton)ApplicationBar.Buttons[0]).Text = AppResources.AppBar2a;
((ApplicationBarIconButton)ApplicationBar.Buttons[1]).Text = AppResources.AppBar2b;
((ApplicationBarIconButton)ApplicationBar.Buttons[2]).Text = AppResources.AppBar2c;
ApplicationBar = ((ApplicationBar)Resources["AppBar0"]);
((ApplicationBarIconButton)ApplicationBar.Buttons[0]).Text = AppResources.AppBar0a;
((ApplicationBarIconButton)ApplicationBar.Buttons[1]).Text = AppResources.AppBar0b;
ApplicationBar.IsMenuEnabled = true;

ApplicationBarMenuItem appBarMenuItem;
appBarMenuItem = new ApplicationBarMenuItem(AppResources.lblLive);
appBarMenuItem.Click += new EventHandler(Click_Live);
if (App.isTrial)
appBarMenuItem = new ApplicationBarMenuItem(AppResources.lblBuyNow);
appBarMenuItem.Click += new EventHandler(Click_Buy);
if (App.EdomDog)
appBarMenuItem = new ApplicationBarMenuItem(AppResources.lblEdomDog);
appBarMenuItem.Click += new EventHandler(Click_EdomDog);

Now, as the app evolves, I have an easy framework to build the appbars on. The code is contained to the page that needs it, it supports multiple languages and it supports optional items.

John Marshall… Visio MVP

Written by johnvisiomvp

January 15, 2014 at 9:42 am

MVA is not just for IT guys

with 2 comments

For the past month I have been looking at MVA – Microsoft Virtual Academy.  I did check it out when it was first released, but it basically had IT Pro related courses. Though I prefer to wear a dev hat, I did play an IT Pro in the past.

My IT Pro experiences were back in the days of the dinosaurs when I roamed mainframes in the basement of a large shopping center. So I am always curious how the industry has progressed. In those days, remote access involved using the phone to get the status from an operator and deciding if the system had to be rebooted. If it dead need rebooting, you had more than enough time to drive in before the system was ready. System testing was done at 2AM Sunday, provided IBM left you a large enough time window. Sometimes you felt you were on a NASCAR pit crew when you tried to see haw fast you could bring down a production system, bring up the test system, run the test(s), bring down the test system, bring up production and then verify it was ready for hand over from the dev team to the prod team. The game has changed, things are far easier, but there are far more interesting things to do and play with.

If you are just curious about a technology, check out one of their courses. It will not give you instant understanding, but it may give you some insight to be comfortable enough to go further.

The beauty of the courses is that they have a rewind button. Each student learns at their own pace and sometimes the instructor comes out with a gem that the student wants to hear again to make sure they understand – press rewind. (On the PowerShell course it was interesting to hear the verb Claused being used with reverence.) So, you took the course last month and aced it. Review the course and see if their are any gems you missed the first time around.

You scanned the PDFs that came with the course, slept through the video, but what sunk in? Most modules in the course come with Self tests that make you think. Can you make the 80% mark and get 100% completion on the course?

So why would a dev be interested in IT courses? Some of the tools used by IT Pros are useful to devs. I spent the weekend enjoying two courses on PowerShell – Getting Started with PowerShell and Advanced PowerShell and now I have a whole slew of questions to ask Clippy. They even have courses on Database Fundamentals, Big Data, Networking Fundaments and more

Over the past month, I got carried away checking out the various courses and made it to #1 in the Top Students in Canada for the week. I have slipped to #3, but I am now #2 in Canada for the month. So join me on the Top Student board and enjoy the learning experience.

Here are some developer related courses:
C# Fundamentals: Development for Absolute Beginners
Programming in C# Jump Start
Windows 8
Windows 8 UX Design Jump Start
Essentials of Developing Windows Store Apps using C# Jump Start
Advanced Windows Store App Development using C# Jump Start
XAML Deep Dive for Windows & Windows Phone Apps Jump Start
Developing Windows Store Apps with HTML5 Jump Start
Windows Store Apps with HTML5 Refresh Jump Start
Advanced Windows Store App Development with HTML5 Jump Start
Building Windows Store Apps for iOS Developers Jump Start
Gaming Engines for Windows 8 Jump Start
Windows Phone
Windows Phone 8 Development for Absolute Beginners
Building Apps for Windows Phone 8 Jump Start
Build Apps for Both Windows 8 and Windows Phone 8 Jump Start
Visual Studio/ALM Applying ALM with Visual Studio 2012 Jump Start
Administering Visual Studio TFS 2012 Jump Start
Software Testing with Visual Studio 2012 Jump Start
Developing ASP.NET MVC4 Web Applications Jump Start
HTML5 & CSS3 Fundamentals: Development for Absolute Beginners
Developing in HTML5 with JavaScript and CSS3 Jump Start
Building Web Apps with ASP.NET Jump Start
Developing Microsoft SharePoint® Server 2013 Core Solutions Jump Start
Building Business Apps with Visual Studio Lightswitch

So check out MVA – Microsoft Virtual Academy

John Marshall… Visio MVP

Written by johnvisiomvp

November 25, 2013 at 3:06 pm

WP7/8 Mystery of the screen bounce?

with one comment

I have been working on a new app that required more screen real estate than the phone provided.  All my attempts to get a canvas inside a standard ScrollViewer ended in having the unusual effect that I could not scroll to the bottom or far right. As soon as I took my finger off the screen, the screen would bounce inwards. A little online search indicated that the problem was known, but was not repeatable. Since there are so many unknown variables in a XAML solution, I can not claim that this is the definitive answer.

The thing that helped resolve the issue was changing the  background to something other than black. It is not easy to see the edges of a black shape on a black background. When I did this, I noticed several shapes that extended beyond the canvas and when I tried to scroll to the edge, it snapped back to the canvas that was now visible. I then made sure that I let the program reset the page size to include the wayward shapes. Now I have a WP7/8 app that has a canvas that can be bigger than the screen size and will scroll to the edge correctly.

Now on to finish the app and add it to my collection.

John Marshall… Visio MVP

Written by johnvisiomvp

February 6, 2013 at 2:34 pm