我想在我的WPF應用程序中使用圖標,併爲其他事物使用一些圖標,但是我一直從設計器視圖中收到錯誤,例如「path-x不是有效資源或無法找到。「 - 其中「path-x」是我嘗試使用的任何圖像的路徑。使用WPF中的圖像和圖標
如果正在尋找在正確的地方,我敢打賭,它會發現它;)
,但隨後,它決定給不給我這個錯誤了。所以,我繼續點擊Run(F5),在標題欄中看到我的新圖標。只有與此獸對質:
「System.Windows.Markup.XamlParseException 發生消息= System.Windows.Baml2006.TypeConverterMarkupExtension‘上 提供價值' 引發了異常。’行號 '5' 和 線位置 '50'
源= PresentationFramework
LineNumber上= 5 LinePosition = 50
堆棧跟蹤: 在System.Windows.Markup.XamlReader.RewrapException(例外 E,IXamlLineInfo lineInfo,烏里 基本URI) 在System.Windows.Markup.WpfXamlLoader.Load(xamlReader xamlReader,IXamlObjectWriterFactory writerFactory,布爾 skipJournaledProperties,對象 rootObject,XamlObjectWriterSettings 設置,烏里基本URI) 在System.Windows.Markup.WpfXamlLoader.L oadBaml(XamlReader xamlReader,布爾 skipJournaledProperties,對象 rootObject,XamlAccessLevel ACCESSLEVEL,烏里基本URI) 在System.Windows.Markup.XamlReader.LoadBaml(流 流,ParserContext parserContext, 對象的父,布爾closeStream) 在系統.Windows.Application.LoadComponent(對象 組件,烏里resourceLocator) 在One_Stop_Management.MainWindow.InitializeComponent() 在C:\用戶\傑森\文檔\ 2010的Visual Studio的 \項目\一站式 管理\一站式 管理\ MainWindow.xaml:第1行 在O C:\ Users \ Jason \ Documents \ Visual Studio 2010 \ Projects \ One Stop Management \ One Stop Management \ MainWindow.xaml.cs:line 25 InnerException:System.IO .IOException Message =找不到資源'images/favicon.ico'。 源= PresentationFramework 堆棧跟蹤: 在MS.Internal.AppModel.ResourcePart.GetStreamCore(的FileMode 模式,FileAccess的訪問) 在System.IO.Packaging.PackagePart.GetStream(的FileMode 模式,FileAccess的訪問) 在System.IO .Packaging.PackWebResponse.CachedResponse.GetResponseStream() 在System.IO.Packaging.PackWebResponse.GetResponseStream() 在System.IO.Packaging.PackWebResponse.get_ContentType() 在System.Windows.Media.Imaging.BitmapDecoder。SetupDecoderFromUriOrStream(URI URI,流流,BitmapCacheOption cacheOption,的Guid & CLSID,布爾& isOriginalWritable,流& uriStream, UnmanagedMemoryStream & unmanagedMemoryStream,SafeFileHandle & safeFilehandle) 在System.Windows.Media.Imaging.BitmapDecoder.CreateFromUriOrStream (Uri baseUri,Uri uri,Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy, Boolean insertInDecoderCa CHE) 在System.Windows.Media.Imaging.BitmapFrame.CreateFromUriOrStream(URI 基本URI,URI的Uri,流流, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy) 在System.Windows.Media.ImageSourceConverter.ConvertFrom( ITypeDescriptorContext 方面,CultureInfo的文化,對象 值) 在System.Windows.Baml2006.TypeConverterMarkupExtension.ProvideValue(IServiceProvider的 的ServiceProvider) 在MS.Internal.Xaml.Runtime.ClrObjectRuntime.CallProvideValue(的MarkupExtension 我的IServiceProvider的ServiceProvider) 的InnerException :「
爲什麼這件事情給我的態度?我只是想插入圖片...
更新
下面是製作的圖標,當我試圖使用添加圖標的屬性面板的XAML:
<Fluent:RibbonWindow x:Class="One_Stop_Management.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Fluent="clr-namespace:Fluent;assembly=Fluent"
Title="One Stop Management" Height="727" Width="1208" Icon="Resources\favicon.ico">
最新
我甚至不能添加使用屬性窗格中的圖標,下面是它給我的錯誤。
你可以分享試圖插入圖像的XAML嗎? – 2011-04-08 23:47:17
是的。我現在正在更新。 – 2011-04-08 23:57:35
@Craig,將其添加到問題的底部。謝謝。 – 2011-04-08 23:59:22