Tuesday, March 31, 2015

Windows 10 Dev Tool Preview - Views?

Let's say you have two versions of your XAML, Page1_Phone and Page1_PC or something. Each of those has a code behind (Page1_Phone.xaml.cc & Page1_PC.xaml.cs). Each of these pages should belong to the same class (e.g. Page1), but you'll navigate to the appropriate page depending on platform.


Create a 3rd code-behind file (e.g. Page1_Shared.xaml.cs) and make it a partial class:


public partial sealed class Page1


Put all your shared code in there and your platform-specific in the other files. It's all compiled to the same class.


I did a blog post recently (blog.grogansoft.com) about this very topic for Windows 8.1 apps (it should be a little different for Windows 10 because you don't have multiple projects necessarily). The post explains it in more detail, so have a look if the above doesn't make sense.


EDIT: p.s. You might want to upload an avatar image to your account because the random image generator gave you a rather unfortunate one.




I'm a self-taught noob amateur. Please take this into account when responding to my posts or when taking advice from me.



No comments:

Post a Comment