Rob Kraft's Software Development Blog

Software Development Insights

Archive for the ‘Silverlight’ Category

How to prevent foreign language subfolders in Silverlight 5.0 projects

Posted by robkraft on April 17, 2016

This is an update to a blog post I first made in 2011:  https://csharpdeveloper.wordpress.com/2011/04/02/how-to-prevent-foreign-language-subfolders-in-silverlight-projects/

We are still supporting Silverlight applications, though we should have them rewritten in HTML within a year.  Until then, we can put the commands below into a batch file and run it as Admin on developer PCs to stop the creation of all the foreign language versions of the DLLs of our projects.  This speeds up the build time a little bit, and keeps us from distributing, analyzing, virus-checking, and etc. on those DLLS.

c:
cd\
cd \Program Files (x86)\Microsoft SDKs\Silverlight\v5.0\Libraries\Client
rd ar /S /Q
rd bg /S /Q
rd ca /S /Q
rd cs /S /Q
rd da /S /Q
rd de /S /Q
rd el /S /Q
rd es /S /Q
rd et /S /Q
rd eu /S /Q
rd fi /S /Q
rd fr /S /Q
rd he /S /Q
rd hr /S /Q
rd hu /S /Q
rd id /S /Q
rd it /S /Q
rd ja /S /Q
rd ko /S /Q
rd lt /S /Q
rd lv /S /Q
rd ms /S /Q
rd nl /S /Q
rd no /S /Q
rd pl /S /Q
rd pt /S /Q
rd pt-BR /S /Q
rd ro /S /Q
rd ru /S /Q
rd sk /S /Q
rd sl /S /Q
rd sr-Cyrl-CS /S /Q
rd sr-Latn-CS /S /Q
rd sv /S /Q
rd th /S /Q
rd tr /S /Q
rd uk /S /Q
rd vi /S /Q
rd zh-Hans /S /Q
rd zh-Hant /S /Q

cd\
cd \Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v5.0
rd de /S /Q
rd es /S /Q
rd fr /S /Q
rd it /S /Q
rd ja /S /Q
rd ko /S /Q
rd ru /S /Q
rd zh-Hans /S /Q
rd zh-Hant /S /Q

 

 

 

Posted in Silverlight, Uncategorized | Leave a Comment »

How to programmatically make the Windows Phone 7 Keyboard open

Posted by robkraft on May 15, 2011

I wrote a Windows Phone 7 application with a search page.  When a user clicks on the search icon I wanted to take them to the search page, set focus on the text box, and have the on phone keyboard pop open for the TextBox.  Since the TextBox was the only control on the page I figured it would get focus and the keyboard would open up; but it didn’t work that way.  To make it work, I used the Focus event on the TextBox.  The only trick to this is that you can’t call the .Focus on the TextBox in page constructor because the XAML has not all rendered and events are not yet tied to all the page elements.  So, you need to create a load event in the constructor, and have the load event call Focus on your textbox.  This will cause the keyboard to open as soon as someone navigates to the page.

public SearchPage
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(SearchPage_Loaded);
}

void SearchPage_Loaded(object sender, RoutedEventArgs e)
{
SearchBox.Focus();
}

Posted in Code Design, Silverlight, Windows Phone 7 | 1 Comment »

BooleanToVisibility Converter – Yes, you must write your own for your Phone

Posted by robkraft on May 6, 2011

You must code your own BooleanToVisibilityConverter in Windows Phone 7 development as of May 2011.  That may change when Silverlight 4 can be used for Phone 7 development.  Until then, I recommend you write your own, and start with a good example like the ones found here:

http://compiledexperience.com/blog/posts/useful-calue-converters

I spent more time than I expected on this project attempting to use a boolean value in my viewmodel to control the visibility of an error message on the form.  What I learned is that I DO need to write my own Converter class that implements Iconverter.  I had the impression from many blog posts that this was built it, but it is not – at least not in Windows Phone 7 with Visual Studio 2010 after the NoDo updates and all Phone SDK updates available through April of 2010.  I did not have to write my own converter though, I just copied this code I found elsewhere on the net.  Then I had to make 3 entries in my XAML:

  1. xmlns:loc=”clr-namespace:MyAppNamespace” where MyAppNamespace is the namespace over the class containing my converting.  This entry was already in my XAML for other purposes – and of course “loc” is just a variable name that you can replace with anything.
  2. Add this little bit of code in the Xaml after the first big block that imports the namespaces.  The name BooleanToVisibilityConverter needs to be the class name of the class you created for this.
    <phone:PhoneApplicationPage.Resources>

<loc:BooleanToVisibilityConverter x:Key=”BooleanToVisibility” />

</phone:PhoneApplicationPage.Resources>

  1. Then use it on one to many Visibility properties with code like the following.  In this case, I have a property named SearchFactsFound on my ViewModel.

Visibility=”{Binding SearchFactsFound, Converter={StaticResource BooleanToVisibility}}”

Posted in Silverlight, Windows Phone 7 | 1 Comment »

How to programmatically switch to a new pivot item in Windows Phone 7

Posted by robkraft on April 3, 2011

I hope the title of my article does not mislead you, but I just learned today that you cannot programmatically change which pivot item is displayed in the pivot control from your C# code. Apparently this is a known bug:
http://stackoverflow.com/questions/4541020/pivotcontrol-item-changing-behavior-in-silverlight-windows-phone-7.

Unfortunately for me this is a fairly devasting problem because my whole user interface (UI) is based on the Pivot Control and I needed my search function in the application to send me to a specific PivotItem. But code like this does not work:

PivotControl.SelectedIndex = 3;

I spent an hour or two before I started writing my application trying to decide if a Pivot Control or non Pivot based UI would work best. Had I known that the pivotcontrol was not working as expected, I certainly would have not used it. Fortunately I have also been writing unit tests and using MVVM on this project which is going to make putting an entirely different UI on the application relatively simple. I estimate 2 to 8 hours. Of course since I only work on this on the evenings and weekends the calendar time is going to cost me a week.

I am using the latest Microsoft Phone Developer SDK (release in February 2011). Hopefully the next SDK will fix this bug.

Posted in Code Design, Silverlight, Visual Studio 2010 | 3 Comments »

How to prevent foreign language subfolders in Silverlight projects

Posted by robkraft on April 2, 2011

I like to keep my folders and libraries clean, and one thing I find annoying is the generation of subfolders and DLLs for to support foreign languages when I have no interest in providing that support in my application.  Specifically, when I am developing Silverlight applications I notice many subfolders like ar, bg, zh-hans, sr-cryl-cs, and es.  If you want to keep your compile from generating those subfolders, you can do this by deleting all the foreign language subfolders that were created by the installation of Silverlight.
This can be tedious, especially if you want to delete them on several machines.  So I created this simple batch file to do it for me.  You may need to change the silverlight folder, and there will probably be additional langauges added, but this may provide you a starter batch file.

c:
cd\
cd "program files\microsoft silverlight\4.0.60129.0\"
rd ar /S /Q
rd bg /S /Q
rd ca /S /Q
rd cs /S /Q
rd da /S /Q
rd de /S /Q
rd el /S /Q
rd es /S /Q
rd et /S /Q
rd eu /S /Q
rd fi /S /Q
rd fr /S /Q
rd he /S /Q
rd hr /S /Q
rd hu /S /Q
rd id /S /Q
rd it /S /Q
rd ja /S /Q
rd ko /S /Q
rd lt /S /Q
rd lv /S /Q
rd ms /S /Q
rd nl /S /Q
rd ru /S /Q
rd zh-hans /S /Q
rd zh-hant /S /Q
rd no /S /Q
rd pl /S /Q
rd pt /S /Q
rd pt-br /S /Q
rd ro /S /Q
rd sk /S /Q
rd sl /S /Q
rd sr-cyrl-cs /S /Q
rd sr-latn-cs /S /Q
rd sv /S /Q
rd th /S /Q
rd tr /S /Q
rd uk /S /Q
rd vi /S /Q

cd\
cd "Program Files\Microsoft SDKs\Silverlight\v4.0\Libraries\Client\"
rd ar /S /Q
rd bg /S /Q
rd ca /S /Q
rd cs /S /Q
rd da /S /Q
rd de /S /Q
rd el /S /Q
rd es /S /Q
rd et /S /Q
rd eu /S /Q
rd fi /S /Q
rd fr /S /Q
rd he /S /Q
rd hr /S /Q
rd hu /S /Q
rd id /S /Q
rd it /S /Q
rd ja /S /Q
rd ko /S /Q
rd lt /S /Q
rd lv /S /Q
rd ms /S /Q
rd nl /S /Q
rd ru /S /Q
rd zh-hans /S /Q
rd zh-hant /S /Q
rd no /S /Q
rd pl /S /Q
rd pt /S /Q
rd pt-br /S /Q
rd ro /S /Q
rd sk /S /Q
rd sl /S /Q
rd sr-cyrl-cs /S /Q
rd sr-latn-cs /S /Q
rd sv /S /Q
rd th /S /Q
rd tr /S /Q
rd uk /S /Q
rd vi /S /Q

Posted in Dev Environment, Silverlight | Leave a Comment »

IIS 5.1 on Windows XP does not a good Silverlight test server make

Posted by robkraft on November 4, 2010

Today we resolved a few problems in our Silverlight application that manifested as [Async_ExceptionOccurred] and “Remote server not found” errors.  Our testing server was running IIS 5.1 on Windows XP.  IIS on Windows XP is limited to just 10 connections.  Since IE8 may be using up to 6 connections at a time, and during testing we often have multiple users, the maximum number of connections is exceeded and errors occur.  We found HTTP response code 403 (http://en.wikipedia.org/wiki/HTTP_403) in the logfiles of the IIS server.  I guess that we specifically were getting 403.9 “Too many users”, but that detail is not included in our log file.  Using Fiddler we saw some of the errors as 504 (the very same requests that IIS logged as 403).  The 504 did not seem accurate though because the failure response occurred immediately and our WCF timeouts are all set to 10 minutes.

 I thought I’d post what we found hoping it hastens others experiencing similar problems to a resolution.

Posted in Silverlight | Tagged: | Leave a Comment »