is there any difference between defining the variable as a static member in the App class like this:
public static string myValue;
//
string value = App.myValue;
and using the (App.Current as App) to retrieve the property of the App like this:
public string myValue { set; get; }
//
string value = (App.Current as App).myValue
If
Appis derived fromApplication, than almost no difference.The small difference is at the very program beginning (in
Main, for instance)App.Currentis stillnull, whereas the static property will already be accessible. This is because theApplicationclass is not a real singleton (or rather thatCurrentdoesn’t trigger its creation — this behaviour is at least for WPF 3.5).The other small difference is of course that in the first case
myValueis a field and not a property — so some scenarios which expect properties (like binding etc.) would fail.