How do I work with images in a portable class library targeting Windows Store Apps and WP7,WP8,WPF?

后端 未结 7 1074
忘掉有多难
忘掉有多难 2020-12-31 00:23

I am working on a first PCL that targets : WSA (Windows Store Application), WPF,WP7,WP8. We can say that it is a rolerdex kind of application, you have contacts , they have

7条回答
  •  北海茫月
    2020-12-31 00:57

    I would probably put the actual image files in each app. I don't think you get much value out of trying to embed them in the PCL.

    In your portable ViewModels, you can reference the image via a Uri. Unfortunately that Uri needs to be different on each platform. For Windows Store apps it needs to be something like ms-appx:////Assets/image.png where for Windows Phone I think it will just be /Assets/image.png.

    So you'll need some code to figure out the correct Uri format. That could be a platform-specific service with a portable interface that the ViewModels would call. You might also be able to create a binding converter that would do whatever conversion you needed.

    There are certainly other ways of doing this-- this is just what I'd picked based on the information in your question.

提交回复
热议问题