Get the Windows Phone 7 Application Title from Code

后端 未结 5 672
失恋的感觉
失恋的感觉 2020-12-28 21:27

I want to access the Title value that is stored in the WMAppManifest.xml file from my ViewModel code. This is the same application title that is set through the project prop

5条回答
  •  隐瞒了意图╮
    2020-12-28 22:01

    The problem with all of those answers is that they have to read the file every single time it is accessed. This is bad for performance as there are battery issues to consider if you use it frequently. Koen was closer to a proper solution, but his design still went back to the file every time you wanted to access the value.

    The solution below is a one-and-done read of the file. Since it is not likely to change, there is no reason to keep going back to it. The attributes are read as the static class is initialized, with minimal fuss.

    I created this Gist to demonstrate.

    HTH!

提交回复
热议问题