2010-03-12 37 views
0

期間所討論的圖像位於一個的ControlTemplate ResourceDictionary中類似的內部到這個(各種細節爲了清楚而移除):圖像顯示在表達混合但不運行時

<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"> 
    <ControlTemplate x:Key="ImageTestTemplate" TargetType="ImageTest"> 
     <Grid> 
      <Image Source="/MyAssembly;Component/Images/MyImage.png"/> 
     </Grid> 
    </ControlTemplate> 
</ResourceDictionary> 

當我認爲在表達控制混合圖像顯示出來很好,但是當我運行應用程序時,圖像不顯示。如果我將相同的圖像放到UserControl中,它也顯示出來很好,所以問題與使用模板有關。

有沒有其他方法我應該加載模板內的圖像資源?

+0

我最終做了一個新的用戶控件,它基本上是一個Image控件的包裝。它有一個屬性「Source」,它只是包裝圖像控件的「Source」屬性的傳遞。從模板中使用這個包裝控件工作得很好。 – onedozenbagels 2010-03-14 14:19:12

回答

0

我不認爲你需要領先的'/'。我用於項目的基本資源路徑是SL 3中的「IMLPrototype2; component/Model/Sounds /」& 4.

+0

我試過沒有領先的'/'。它仍然不顯示。 – onedozenbagels 2010-03-14 14:16:02

相關問題