Using icons in the toaster message

Feb 2, 2015 at 1:54 PM
Hello group, I have a question: I try to put a icon in the toaster message by assigning a .png file to the Image property but it don't seem to work. Is it only possible to use bitmap?
Any help would be appreciated. Richard
Coordinator
Feb 4, 2015 at 9:04 PM
Hello,

Sorry for the delay.
You should be able to add any png you want:
<toastinet:Toastinet x:Name="Toast"
      Title="Toastinet"
      Message="{Binding Message, Mode=TwoWay}"
      Image="toast.png"
      Canvas.ZIndex="1"
      Queued="True"
      VerticalAlignment="Top" />
Are you sure the png's path is well formed ?
Feb 5, 2015 at 10:14 AM
Hello, here is my problem in more details:

In my XAML:

<toastinetWpf:Toastinet x:Name="Toast4"
                         Duration="120"
                         Height="50"
                         ShowLogo="False"
                         FontSize="15"
                         TextHAlignment="Center"
                         AnimationType="Vertical"
                         Background="#FFE64329"
                         Foreground="Black"
                         Image="ApplicationIcon.png"
                         TextWrapping="Wrap"
                         Canvas.ZIndex="1"
                         VerticalAlignment="Top" />
The error I get is:

System.Windows.Data Error: 6 : 'TargetDefaultValueConverter' converter failed to convert value '/Assets/ApplicationIcon.png' (type 'String'); fallback value will be used, if available. BindingExpression:Path=Data.Image; DataItem='BindingProxy' (HashCode=12177951); target element is 'Image' (Name=''); target property is 'Source' (type 'ImageSource')
IOException:'System.IO.IOException: Cannot locate resource 'assets/applicationicon.png'.
at MS.Internal.AppModel.ResourcePart.GetStreamCore(FileMode mode, FileAccess access)
at System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access)
at System.IO.Packaging.PackWebResponse.CachedResponse.GetResponseStream()
at System.IO.Packaging.PackWebResponse.GetResponseStream()
at System.IO.Packaging.PackWebResponse.get_ContentType()
at System.Windows.Media.Imaging.BitmapDecoder.SetupDecoderFromUriOrStream(Uri uri, Stream stream, BitmapCacheOption cacheOption, Guid& clsId, Boolean& isOriginalWritable, Stream& uriStream, UnmanagedMemoryStream& unmanagedMemoryStream, SafeFileHandle& safeFilehandle)
at System.Windows.Media.Imaging.BitmapDecoder.CreateFromUriOrStream(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy, Boolean insertInDecoderCache)
at System.Windows.Media.Imaging.BitmapFrame.CreateFromUriOrStream(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy)
at System.Windows.Media.ImageSourceConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)
at MS.Internal.Data.TargetDefaultValueConverter.Convert(Object o, Type type, Object parameter, CultureInfo culture)
at System.Windows.Data.BindingExpression.ConvertHelper(IValueConverter converter, Object value, Type targetType, Object parameter, CultureInfo culture)'

I have not specified a path to: assets/applicationicon.png or /Assets/ApplicationIcon.png in the setting of the Image property.

I have the file (ApplicationIcon.png) in a subfolder Assets (uppercase 'A') and in my top level project folder (ToastinetWPFSample) but I get this error.

Do you have any solution?

Thanks,
Richard
Coordinator
Feb 5, 2015 at 10:41 AM
Hmm, Richard, are you sure to have the latest version of Toastinet ?

I've looked at the source code and the "BindingProxy" I see in your error's message is no more used.
So it should not appear in the error log.

By the way, if you want to display the icon, you have to set the "ShowLogo" property to "True".


If you have problem with latest version, I will investigate in depth.

Regards,
Guillaume
Feb 6, 2015 at 2:39 PM
Hello there,

I have picked up version 1.5 and tried again but no success.

XAML:
    <toastinetWpf:Toastinet x:Name="Toast2"
                         Duration="5"
                         Height="100"
                         ShowLogo="True"
                         FontSize="15"
                         TextHAlignment="Center"
                         AnimationType="Vertical"
                         Background="#2ecc71"
                         Foreground="Black"
                            Image="toast.png"
                         TextWrapping="Wrap"
                         Canvas.ZIndex="1"
                         VerticalAlignment="Top" />
This image (toast.png) is used in a Image control on the same page so I am sure this one should be locatable for the application. The output I get:

System.Windows.Data Error: 6 : 'TargetDefaultValueConverter' converter failed to convert value 'toast.png' (type 'String'); fallback value will be used, if available. BindingExpression:Path=Data.Image; DataItem='BindingProxy' (HashCode=4875788); target element is 'Image' (Name=''); target property is 'Source' (type 'ImageSource') IOException:'System.IO.IOException: Cannot locate resource 'toast.png'.
at MS.Internal.AppModel.ResourcePart.GetStreamCore(FileMode mode, FileAccess access)
at System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access)
at System.IO.Packaging.PackWebResponse.CachedResponse.GetResponseStream()
at System.IO.Packaging.PackWebResponse.GetResponseStream()
at System.IO.Packaging.PackWebResponse.get_ContentType()
at System.Windows.Media.Imaging.BitmapDecoder.SetupDecoderFromUriOrStream(Uri uri, Stream stream, BitmapCacheOption cacheOption, Guid& clsId, Boolean& isOriginalWritable, Stream& uriStream, UnmanagedMemoryStream& unmanagedMemoryStream, SafeFileHandle& safeFilehandle)
at System.Windows.Media.Imaging.BitmapDecoder.CreateFromUriOrStream(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy, Boolean insertInDecoderCache)
at System.Windows.Media.Imaging.BitmapFrame.CreateFromUriOrStream(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy)
at System.Windows.Media.ImageSourceConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)
at MS.Internal.Data.TargetDefaultValueConverter.Convert(Object o, Type type, Object parameter, CultureInfo culture)
at System.Windows.Data.BindingExpression.ConvertHelper(IValueConverter converter, Object value, Type targetType, Object parameter, CultureInfo culture)'

Thanks in advance for your help.

Richard
Coordinator
Feb 19, 2015 at 2:18 PM
Sorry for the delay...

I just realized that you took the version 1.5 from the Download category in CodePlex.
You should take the version 1.6 from Nuget .

In fact, the package available in download category at the top of the page is not up to date. Each time I made a change, I have to reupload a package, it's a little bit boring.
So, I only use TFS to checkin source directly from Visual Studio to Codeplex and Publish a Nuget package.

I'm going to delete this obsolete package. Sorry for the inconvenience.

Guillaume
Feb 24, 2015 at 2:03 PM
Yes great version 1.6 works. I got this version from Nuget.

One more request: can you also post the sources for us?

Thanks in advance,

Richard
Coordinator
Feb 24, 2015 at 2:37 PM
Glad to heard that :)

Latest source are available in the SOURCE CODE tab at the top of the page.

You can view history of changesets:
http://toastinet.codeplex.com/SourceControl/list/changesets


Regards,
Guillaume