add toast at runtime

Aug 14, 2014 at 5:17 PM
Is there a way to add toast at runtime instead of adding in xaml. I tried some basic tests but it never shows up

//some event happens and we want to add toast at runtime

var t = new Toastinet();
        t.Height = 105;
        t.VerticalAlignment = VerticalAlignment.Top;
        MainG.Children.Add(t); //add to mainWindow Grid
        t.Message = "This toast is listening for closing/closed events";
        t.Closing += ToastOnClosing;
        t.Closed += ToastOnClosed;
Aug 14, 2014 at 7:23 PM
These errors get displayed in immediate window

m.Windows.Data Error: 40 : BindingExpression path error: 'InvertedHeight' property not found on 'object' ''MainWindow' (Name='PageRoot')'. BindingExpression:Path=Data.InvertedHeight; DataItem='BindingProxy' (HashCode=52844977); target element is 'DoubleAnimation' (HashCode=47380263); target property is 'To' (type 'Nullable1')
System.Windows.Data Error: 40 : BindingExpression path error: 'InvertedHeight' property not found on 'object' ''MainWindow' (Name='PageRoot')'. BindingExpression:Path=Data.InvertedHeight; DataItem='BindingProxy' (HashCode=52844977); target element is 'DoubleAnimation' (HashCode=63542621); target property is 'To' (type 'Nullable
1')
System.Windows.Data Error: 40 : BindingExpression path error: 'InvertedHeight' property not found on 'object' ''MainWindow' (Name='PageRoot')'. BindingExpression:Path=Data.InvertedHeight; DataItem='BindingProxy' (HashCode=52844977); target element is 'DoubleAnimation' (HashCode=55110660); target property is 'To' (type 'Nullable1')
System.Windows.Data Error: 40 : BindingExpression path error: 'WidthToClosed' property not found on 'object' ''MainWindow' (Name='PageRoot')'. BindingExpression:Path=Data.WidthToClosed; DataItem='BindingProxy' (HashCode=52844977); target element is 'DoubleAnimation' (HashCode=44944564); target property is 'To' (type 'Nullable
1')
System.Windows.Data Error: 40 : BindingExpression path error: 'WidthToOpened' property not found on 'object' ''MainWindow' (Name='PageRoot')'. BindingExpression:Path=Data.WidthToOpened; DataItem='BindingProxy' (HashCode=52844977); target element is 'DoubleAnimation' (HashCode=30787823); target property is 'To' (type 'Nullable`1')
System.Windows.Data Error: 40 : BindingExpression path error: 'TextHAlignment' property not found on 'object' ''MainWindow' (Name='PageRoot')'. BindingExpression:Path=Data.TextHAlignment; DataItem='BindingProxy' (HashCode=52844977); target element is 'StackPanel' (Name=''); target property is 'HorizontalAlignment' (type 'HorizontalAlignment')
System.Windows.Data Error: 40 : BindingExpression path error: 'Image' property not found on 'object' ''MainWindow' (Name='PageRoot')'. BindingExpression:Path=Data.Image; DataItem='BindingProxy' (HashCode=52844977); target element is 'Image' (Name=''); target property is 'Source' (type 'ImageSource')
System.Windows.Data Error: 40 : BindingExpression path error: 'ShowLogo' property not found on 'object' ''MainWindow' (Name='PageRoot')'. BindingExpression:Path=Data.ShowLogo; DataItem='BindingProxy' (HashCode=52844977); target element is 'Image' (Name=''); target property is 'Visibility' (type 'Visibility')
System.Windows.Data Error: 40 : BindingExpression path error: 'ShowLogo' property not found on 'object' ''MainWindow' (Name='PageRoot')'. BindingExpression:Path=Data.ShowLogo; DataItem='BindingProxy' (HashCode=52844977); target element is 'TextBlock' (Name=''); target property is 'Visibility' (type 'Visibility')
System.Windows.Data Error: 40 : BindingExpression path error: 'TextWrapping' property not found on 'object' ''MainWindow' (Name='PageRoot')'. BindingExpression:Path=Data.TextWrapping; DataItem='BindingProxy' (HashCode=52844977); target element is 'TextBlock' (Name='ToastMsg'); target property is 'TextWrapping' (type 'TextWrapping')
System.Windows.Data Error: 6 : 'TargetDefaultValueConverter' converter failed to convert value '/Toastinet;component/Assets/tile.png' (type 'String'); fallback value will be used, if available. BindingExpression:Path=Data.Image; DataItem='BindingProxy' (HashCode=52844977); target element is 'Image' (Name=''); target property is 'Source' (type 'ImageSource') FileNotFoundException:'System.IO.FileNotFoundException: Could not load file or assembly 'Toastinet, Culture=neutral' or one of its dependencies. The system cannot find the file specified.
File name: 'Toastinet, Culture=neutral'
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at System.Windows.Navigation.BaseUriHelper.GetLoadedAssembly(String assemblyName, String assemblyVersion, String assemblyKey)
at MS.Internal.AppModel.ResourceContainer.GetResourceManagerWrapper(Uri uri, String& partName, Boolean& isContentFile)
at MS.Internal.AppModel.ResourceContainer.GetPartCore(Uri uri)
at System.IO.Packaging.Package.GetPartHelper(Uri partUri)
at System.IO.Packaging.Package.GetPart(Uri partUri)
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)

=== Pre-bind state information ===
LOG: DisplayName = Toastinet, Culture=neutral
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Toastinet, Culture=neutral | Domain ID: 1
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Users/dans/Desktop/toastinet v1.5/toastinet/ToastinetWPFSample/bin/Debug/
LOG: Initial PrivatePath = NULL

Calling assembly : PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.

LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\dans\Desktop\toastinet v1.5\toastinet\ToastinetWPFSample\bin\Debug\ToastinetWPFSample.vshost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
'