Windows phone header same for all pages

不问归期 提交于 2019-12-07 12:06:46

问题


Im creating an App and I have a header that its the same for all pages (a footer as well, but that one ill create using the app bar).

My question is, what's the best way to do this if I dont want to repeat the header (code it) in every page.

Thank you.


回答1:


The best was to do this is create the following:

  1. UserControl for the Header
  2. UserControl for the Footer
  3. Everything Page or UserControl should show these items.



回答2:


Look at templating your project so that you can have multiple views and and multiple regions

I would also look at Prism: http://msdn.microsoft.com/en-us/library/gg406140.aspx




回答3:


Depends what you use as header and footer, if it is a simple text then you could use the default page templates and Bind the text to a static resource defined in the App.Xaml, if it is more complex then you could create a user control as suggested. You could create animations too and play this when your page is displayed.

Static resource in App.Xaml as an Application.Resource :

<Application.Resources>
     <sys:String x:Key="applicationTitle">Your Title!</sys:String>
</Application.Resources>

You need to add this namespace to the App.Xaml too :

 xmlns:sys="clr-namespace:System;assembly=mscorlib" 

Or you could use MVVM too to create a View and a ViewModel for the header. If you are new to MVVM then take a look at Galasofts MVVM light.

GalaSoft MVVM



来源:https://stackoverflow.com/questions/8930580/windows-phone-header-same-for-all-pages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!