The directory settings are as follows:
Scenario 1: Set the PNG file to Resource,do not copy.
Specify the source code for Image:
Spirit. Source = new BitmapImage (The new Uri (@ "player/" + Count + ". png", urikind.relative));
Note that the relative path is used, the position of the current MainPage.xaml relative to the picture, and the server path cannot be used.
If we specify the source of image in spirit, which means that the relative path is changed, then the code is written as:
Body.source = new BitmapImage (The new Uri (@). /player/2.png ", urikind.relative));
In this case, all the pictures are embedded as resources into the DLL, observing the organizational structure in the XAP, can confirm our conclusion:
Scenario 2: Set the PNG file to content,copy if newer.
Specify the source code for Image:
Spirit. Source = new BitmapImage (The new Uri (@ "/player/" + Count + ". png", urikind.relative));
Note that the server path is used instead of the relative path.
One advantage of using the server path is that, regardless of where the XAML resides in that directory, it can be ignored, such as the Spirit control above:
Body.source = new BitmapImage (The new Uri (@ "/player/2.png", urikind.relative));