2013-03-22 35 views
0

我是XAML的新手,正在嘗試創建一個基本功能區。我這裏有一些代碼:LargeImageSource拋出異常

<RibbonWindow x:Class="MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:r="clr-  namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary" 
    Title="MainWindow" 
    x:Name="RibbonWindow" 
    Width="640" Height="480"> 

<Grid x:Name="LayoutRoot"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="*"/> 
    </Grid.RowDefinitions> 

    <Ribbon x:Name="Ribbon" Title="Ribbon Title"> 
     <r:RibbonButton Width="100" Background="Azure" Height="100" > 

     </r:RibbonButton> 
     <r:RibbonButton x:Name="RibbonButton" Label="Button" LargeImageSource="Icons/disk.png"> 


     </r:RibbonButton> 

    </Ribbon> 
</Grid> 

我得到的代碼的LargeImageSource部分例外。我不知道爲什麼。圖像在設計器中呈現,構建時不會生成錯誤,但我無法運行該項目。

這裏是例外:

類型 'System.Windows.Markup.XamlParseException' 的未處理的異常發生在PresentationFramework.dll

其他資料: '提供關於值' System.Windows.Baml2006。 TypeConverterMarkupExtension'拋出一個異常。'行號「19」和行位置「51」。

如果有這種異常的處理程序,程序可能會安全地繼續。

任何幫助,將不勝感激。

問候

回答

0

它已經停止生產的誤差(因爲某些原因)。這與使用.png文件有關,儘管我不知道該怎麼做。我玩弄了各種屬性並使其運行起來。

0

假設"Icons/disk.png"被添加到解決方案資源管理(右鍵點擊項目 - >添加 - >新建文件夾,然後用鼠標右鍵單擊文件夾 - >添加 - >現有項...並選擇映像文件),該項目"disk.png"應該將其屬性設置如下:

Build Action : Content 
Copy to Output Directory : Copy if newer