开发者

How to pass a color value from one to another page in windowsphone 7?

开发者 https://www.devze.com 2023-03-28 05:15 出处:网络
I have a color palette in one X开发者_如何学JAVAAML page. I want to pass the selected colour to another xaml page? As it is a color, string value is giving error, string cannot be converted to System.

I have a color palette in one X开发者_如何学JAVAAML page. I want to pass the selected colour to another xaml page? As it is a color, string value is giving error, string cannot be converted to System.windows.media Can anyone help me in this. Thanks.


You'd pass it the same way you'd pass any non-string value.
There are 2 options:

  1. Store it in an object with a global scope, so both pages/VMs can access the property.

  2. Serialize the object and pass the serialized version. Because a Color does not support serialization directly you'll have to do this yourself. I'd do it by getting the A, R, G & B values of the color and writing them to a (probably delimited) string. Then constructing a new Color instance from the values, on the other page, using FromArgb().


You could also temporarily store it in the State cache.

Have a look at PhoneApplicationService.State

This is accessible from all your pages.

0

精彩评论

暂无评论...
验证码 换一张
取 消