Regarding Item 227 : # in a querystring value causes the value to default to "".

Topics: Bugs
May 12, 2012 at 4:48 PM

I have added this topic as the comments section of the Work Items does not format code correctly. It seems the reason for this error is internal to PhoneApplicationPage and how it parses a Uri from a string to a dictionary. To prove this If I pass in the Uri and parse it manually It works.

Passing it in:

TryInjectQueryString(viewModel, page, e.Uri.ToString());

 The method itself:

protected virtual void TryInjectQueryString(object viewModel, Page page, string uri) {
            var viewModelType = viewModel.GetType();

            if (uri.Contains("?"))
                var queryParams = new System.Collections.Generic.Dictionary<string, string>();

                var queryString = uri.Split('?')[1];
                var querySegments = queryString.Split('&');
                foreach (var segement in querySegments)
                    var keyValuePart = segement.Split('=');
                    if (keyValuePart.Length > 1)
                        var key = keyValuePart[0].Trim();
                        var val = keyValuePart[1].Trim();
                        queryParams.Add(key, val);

                foreach (var pair in queryParams)
                    var property = viewModelType.GetPropertyCaseInsensitive(pair.Key);
                    if (property == null)

                        MessageBinder.CoerceValue(property.PropertyType, pair.Value, page.NavigationContext),

Note this is a quick and dirty hack. I think some discussion on how to fix this correctly is needed.