I'm trying to declare a global var in App.xaml.cs this way:
sealed partial class App : Application
{
public static string SessionKey { get; set; }
. . .
I added a "Loaded" event to the map in MainPage.xaml.cs:
<bm:Map x:Name="galaxyMap" Credentials="ImpeccableOrPerhapsALittleBitPeccable"
Margin="0,0,0,0" MapType="Birdseye" Loaded="galaxyMap_OnLoaded" >
...which event gets the Session Key, assigning it to the global var:
async private void galaxyMap_OnLoaded(object sender, RoutedEventArgs args)
{
try
{
App.SessionKey = await visitsMap.GetSessionIdAsync();
}
catch { }
}
However, when I try to access that value when making a REST call:
String httpqry = String.Format(
"http://dev.virtualearth.net/REST/v1/Locations?addressLine={0}&locality={1}&postalCode=
{2}&adminDistrict={3}&countryRegion={4}&key={5}",
addrElements[STREET_ADDRESS], addrElements[LOCALITY], addrElements[POSTAL_CODE],
addrElements[ST8_PROVINCE], addrElements[COUNTRY]),
App.SessionKey)
...I get a red "SessionKey" and on the dot between "App" and "SessionKey" it says, "Invalid expression term '.'"
-and: "; expected" in the same place, and "Invalid expression term ')'" on the ")" at the end of the call to String.Format().
Why is "App" unrecognized? The class where these errors occur is in the same namespace. Why wouldn't it see the application instance?
Looks like a syntax error. There is one ')' too much:
This ')' should be removed.