How to pass a color value from one to another page in windowsphone 7?
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:
Store it in an object with a global scope, so both pages/VMs can access the property.
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 theA
,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, usingFromArgb()
.
You could also temporarily store it in the State cache.
Have a look at PhoneApplicationService.State
This is accessible from all your pages.
精彩评论