简体   繁体   中英

How to create device-family-specific projects with Windows 10, like on W8.1/WP8.1?

I'm planning to port my WP8.1 app to Windows 10 as a Universal app. I saw that MS added the ability to create a single Universal project, and to create different family-specific folders that contain XAML pages/controls that share a single code-behind file. I don't like a few things about this approach though:

• I can only have different XAML files for different devices, but with the same .cs file, so it wouldn't be easy to create some device-specific UI logic, like animations and stuff

• Since I'd have a single Universal project, I'd have to check at runtime the availability of the APIs/classes I need, instead of being able to see whether I can use them or not at compile time, which is much better in my opinion.

I saw an MVA video where Jerry Nixon and Andy Wigley said that the classic multi-headed Universal projects would still be supported on Windows 10, but I have no idea on how to set them up, and I can't find a documentation anywhere.

Everybody's talking about this single project with shared .cs files, but I'd really feel more comfortable working with a multi-headed project: one for mobile phones, one for desktop/tablets, and possibly a shared project or some sort of PCL to share classes and stuff between the two projects (a shared project like with W8.1/WP8.1 would be awesome).

Any ideas how to do that?

Technically the Windows 8.1 Universal apps were build up from 3 projects. One for Windows 8.1 one for the Phone and a Shared CL. Although there is no template built in for that you can achieve the same result by doing it manually, or create your own templet using the VS Extensibility tools. All you need to do is Create a UAP solution, ad another UAP project, name it accordingly lets say MyProjectName.Phone and a Universal CL named as MyProjectName.Shared reference the shared project in the other two and you are ready to rock...

To target individual Device Families with your project you can specify that intent in the Package.Appmanifest.

<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM