My app is crashing after I clear the Bing Map of its pushpins and then open a flyout. This is what I see in the debugger:
The textblock is definitely not null - it is defined declaratively in XAML.
The List of String (CurrentlyMappedPhotosets) is not null - as you can see, it contains a string / has a count of 1.
The code just before what's seen on the scream shot is:
int count = App.CurrentlyMappedPhotosets.Count;
What could be null here?
Just before this happens, I call ClearMap:
private void ClearMap()
{
var mapLayerChildren = from c in DataLayer.Children select c;
var kinderGarten = mapLayerChildren.ToArray();
for (int i = 0; i < kinderGarten.Count(); i++)
{
if (kinderGarten[i] is Pushpin)
{
DataLayer.Children.Remove(kinderGarten[i]);
}
}
CloseInfobox();
App.CurrentlyMappedPhotosets.Clear();
if (null != App.photosetLocationCollection)
{
App.photosetLocationCollection.Clear();
}
appbarbtnClearMap.IsEnabled = false;
UpdateGUI(false);
}
...which calls UpdateGUI():
private void UpdateGUI(bool resizeMap)
{
appbarbtnRenamePhotoset.IsEnabled = App.CurrentlyMappedPhotosets.Count > 0;
if (resizeMap)
{
ResizeMap();
}
}
Have you looked if the value present in the collection is not null? Any non primitive type class is by default null if not constructed with a value.
So you can have as many null values of the type you are trying to have.
I suggest that you do a test by changing the line to: