为什么我不能从RoamingSettings加载数组?

时间:2014-05-12 09:07:25

标签: windows windows-8 windows-runtime windows-8.1 c++-cx

最初的目标是在ApplicationData::Current->RoamingSettings中存储颜色,但由于“值”容器是IPropertySet,因此我可以存储的类型受限制。

所以,我使用Array<unsigned char, 1U>^来存储RGBA值,如下所示:

ApplicationDataContainer^ roamingSettings = ApplicationData::Current->RoamingSettings;
Color black = Colors::Black;
Array<unsigned char, 1U>^ rgbaIn = ref new Array<unsigned char, 1U>{ black.R, black.G, black.B, black.A };
roamingSettings->Values->Insert("colourArr", PropertyValue::CreateUInt8Array(rgbaIn));
//String for control reasons
roamingSettings->Values->Insert("colourStr", PropertyValue::CreateString(ref new String(L"black")));

Array<unsigned char, 1U>^ rgbaOut = dynamic_cast<Array<unsigned char, 1U>^>(roamingSettings->Values->Lookup("colourArr"));
String^ colour = dynamic_cast<String^>(roamingSettings->Values->Lookup("colourStr"));

此时,rgbaOut数组,而colour的值为"black"

为什么?我该怎么做才能解决这个问题?


我应该提一下rgbaIn是正确构造的,确实包含正确的四个值。

0 个答案:

没有答案