在WPF中隻是在項目根目錄中放入圖檔是沒有辦法以絕對路徑對其調用的。
這裡提供一個可行的方法如下:
首先在solution explorer中找到項目名稱,右擊項目名稱=>Add=>New Folder,
這是會在項目目錄中添加一個檔案夾
為建立檔案夾更名為“Image”如下圖:
右鍵Image=>Add=>Existing Item,在彈出的對話框中選擇要加載的圖檔。
然後進入.xmal檔案中,在Image标簽項添加source屬性就可以了!
<Image x:Name="flower" Source="Image\Status.png" HorizontalAlignment="Center" Height="30" Margin="126,0,130,0" VerticalAlignment="Top" Width="46" DockPanel.Dock="Top" />