how can i set the Icon property of the window inheriting from ModerWindow without errors ?

Mar 17, 2013 at 1:54 PM
when ever i try to set the icon property i get this error

System.Windows.Markup.XamlParseException occurred
HResult=-2146233087
Message='Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '13' and line position '19'.
Source=PresentationFramework
LineNumber=13
LinePosition=19
StackTrace:
   at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
   at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
   at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
   at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
   at Active_Dictionary.MainWindow.InitializeComponent() in c:\Users\Dr. Ahmed\Documents\Visual Studio 2012\Projects\ActiveDict\Active Dictionary\MainWindow.xaml:line 1
   at Active_Dictionary.MainWindow..ctor() in c:\Users\Dr. Ahmed\Documents\Visual Studio 2012\Projects\ActiveDict\Active Dictionary\MainWindow.xaml.cs:line 26
InnerException: System.IO.FileNotFoundException
   HResult=-2147024894
   Message=Could not find file 'C:\Users\Dr. Ahmed\Documents\Visual Studio 2012\Projects\ActiveDict\Active Dictionary\bin\Debug\dictionary.ico'.
   Source=mscorlib
   FileName=C:\Users\Dr. Ahmed\Documents\Visual Studio 2012\Projects\ActiveDict\Active Dictionary\bin\Debug\dictionary.ico
   StackTrace:
        at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
        at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
        at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
        at System.IO.File.Open(String path, FileMode mode, FileAccess access, FileShare share)
        at MS.Internal.AppModel.ContentFilePart.CriticalOpenFile(String filename)
        at MS.Internal.AppModel.ContentFilePart.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 System.Windows.Baml2006.TypeConverterMarkupExtension.ProvideValue(IServiceProvider serviceProvider)
        at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CallProvideValue(MarkupExtension me, IServiceProvider serviceProvider)
   InnerException: 
how can i set it to appear in the task bar withour any errors like this ?
Coordinator
Mar 17, 2013 at 8:03 PM
Edited Mar 17, 2013 at 8:03 PM
The LogoData property value needs to be a valid Geometry value. See also this page on defining a custom logo
Apr 5, 2013 at 9:07 PM
Edited Apr 5, 2013 at 9:09 PM
I think newlogicmaster means that he is trying to set an icon to a button, not the main window.

I have had this same problem but it only happens when debugging my application.

After I set my icon to a button, first I must have the icon in the project, that's obvious, but then I also have to have a copy of the icon(s) in the Debug folder and, in the corresponding folder to the application setup e.g. ../Debug/Images - if you read the error message you will see it says - 'could not find file'.

This problem does not happen after the application is published.

A small bug perhaps??
Coordinator
Apr 6, 2013 at 11:32 AM
Can you show some code (or share a sample project) demonstrating the issue?
Apr 11, 2013 at 2:39 PM
I think I have the same problem : Normally, we go into the properties then define an icon, and in MainWindow.xaml, we add the property Icon="icon.ico" :
<mui:ModernWindow x:Class="TestMUI.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mui="http://firstfloorsoftware.com/ModernUI"
        Title="MainWindow"
        ContentSource="/Pages/Home.xaml"
        Icon="icon.ico">
Is there any other way to get an .ico for the taskbar?
Coordinator
Apr 11, 2013 at 4:49 PM
You still can set a custom .ico as Window icon, mui doesn't change that. Are you sure icon.ico is available in your project?
Apr 11, 2013 at 7:34 PM
Yep, I see it in the properties. But that alone doesn't work. When I add the Icon property in a normal WPF project, it works. But it doesn't in a MUI project. How can you add an icon without this property?
Coordinator
Apr 11, 2013 at 10:18 PM
What do you mean with 'I see it in the properties? Adding an .ico resource and setting the ModernWindow.Icon property in xaml as you have done works fine.
Apr 12, 2013 at 10:58 PM
Let's sum up : We (I assume that is also the newLogicMaster problem) want to get an Icon for our main window. Not a logo (that's easy - and beautiful), but an icon that will be seen on the Explorer for our .exe, and in the taskbar when the app is pinned or launched. Like the "e" from Internet Explorer, or the violet icon from Visual Studio.

What's that ModernWindow.Icon property ? I can't use it anywhere ?
Apr 13, 2013 at 1:35 AM
Hi HadrienB,

The icon you need to set is not related with the ModerWindow or other control, if you the Icon property on any control your icon will work just when the application is running.

The icon used on Shortcuts, Pinned Apps e etc is set on the "Project Properties" and will be a resource of the assembly.
How to: Specify an Application Icon

If I miss something or misunderstood your question, please let me try again.
Coordinator
Apr 13, 2013 at 8:27 PM
glbmarquez is correct, the Icon property is a WPF property derived from the Window class. Nothing mui specific.
Jun 3, 2013 at 5:24 PM
Yeap, this is a non-mui mistake!!

It commonly happens when you forget to make a copy of your icon to Output Directory,
1.- Just select your Icon in your Solution Explorer
2.-In the Properties window, select Copy to Output Directory to Copy Always

It happens in all WPF applications, good luck!
Oct 4, 2013 at 3:30 AM
joelbugarini wrote:
Yeap, this is a non-mui mistake!!

It commonly happens when you forget to make a copy of your icon to Output Directory,
1.- Just select your Icon in your Solution Explorer
2.-In the Properties window, select Copy to Output Directory to Copy Always

It happens in all WPF applications, good luck!
Yes , thanks for your helpful !!!!