Problem solved. But I think my solution looks like just a workaround. In the callback I tried to use LoadImageFromResource to load the image binary from resource file:
void UserControl1::ImagePropertyChanged( __in IXRDependencyObject* pControl, __in XRValue* pOldValue, __in XRValue* pNewValue )
{
IWICBitmap *pImage = NULL;
IXRBitmapImagePtr pBitmap;
GetXRApplicationInstance(&pApplication);
pApplication->LoadImageFromResource(App::GetHInstance(), pNewValue->bstrStringVal, L"XAML_RESOURCE", &pImage);
pApplication->CreateObject(&pBitmap);
pBitmap->SetSource(pImage);
pApplication->Release();
UserControl1 *tempObj;
pControl->QueryInterface(__uuidof(UserControl1), (void**)&tempObj);
tempObj->m_pItemImage->SetSource((IXRImageSource*)pBitmap);
}
However the 2nd argument pResourceName expects a resource ID automatically generated by XRPack in .rc file. For e.g.:
103 XAML_RESOURCE DISCARDABLE "..\\..\\..\\..\\Expression\\Blend_3\\Projects\\WindowsEmbeddedSilverlightApplication1\\WindowsEmbeddedSilverlightApplication1\\img1.png"
Then pResourceName should be MAKEINTRESOURCE(103).
Since the ID is automatically assigned by XRPack, there is no way for me to know the image name to ID mapping dynamically.
So I write a perl script to process .rc file and convert the above line into:
img1.png XAML_RESOURCE DISCARDABLE "..\\..\\..\\..\\Expression\\Blend_3\\Projects\\WindowsEmbeddedSilverlightApplication1\\WindowsEmbeddedSilverlightApplication1\\img1.png"
In VS I configure the script to run after XRPack generates .rc file and before compilation starts. That is how
LoadImageFromResource(App::GetHInstance(), pNewValue->bstrStringVal, L"XAML_RESOURCE", &pImage);
will work.