Also in
Images And ValueConverters -
no images are shown following the code in section "Show images in the DrinkOrderEntityView". 5 extra steps are necessary:
1) Add new "images" subfolder to the "assets" folder in the HappyHour project
2) Add all images in "src\Samples\HappyHour\Mixers\images" to the new folder
3) Edit: (I don't think #3 is actually necessary...added it before I discovered #5 below)
3) Add the PathToImageSourceConverter to App.xaml, which should now look like this:
<Application x:Class="HappyHour.App"
...
xmlns:cocktail="clr-namespace:Cocktail;assembly=Cocktail.SL"
...>
<Application.Resources>
<!-- Resources scoped at the Application level should be defined here. -->
<ResourceDictionary>
<local:AppBootstrapper x:Key="bootstrapper" />
<cocktail:PathToImageSourceConverter x:Key="PathToImageSourceConverter" />
...
4) Delete old "happyhour_logo.png" in "assets" root folder and update image reference in MainPage.xaml to:
<Image Source="/HappyHour;component/assets/images/happyhour_logo.png" Grid.Column="1" />
5) Add a call to base.Configure(); in the first line of AppBootstrapper.Configure();
Also, below in "Customizing the custom convention" the Configure() method should be:
protected override void Configure()
{
// ...
ConfigurePathToImageSourceConverter();}
not
protected override void Configure()
{
// ...
ConfigureImageConverter();
}
...and the ConfigureImageConverter() method should be
private static void ConfigurePathToImageSourceConverter()
{
PathToImageSourceConverter.DefaultPathFilter =
path => string.IsNullOrEmpty(path) ?
null : "/HappyHour;component/assets/images/" + path.Trim();
PathToImageSourceConverter.DefaultMissingImage =
PathToImageSourceConverter.GetImageFromPath("missing_drink.jpg");
}
not
private static void ConfigurePathToImageSourceConverter()
{
PathToImageSourceConverter.PathFilter =
path => string.IsNullOrEmpty(path) ?
null : "/HappyHour;component/assets/images/" + path.Trim();
PathToImageSourceConverter.MissingImage =
PathToImageSourceConverter.GetImageFromPath("missing_drink.jpg");
}
Edited by dcuccia - 03-Jun-2012 at 9:29pm