2010-07-08 65 views
0

我有一個自定義控件擴展圖像,我會把一些更多的數據在該圖像的頂部。然而,當我試圖風格的組成部分,我得到的錯誤,我的自定義控件沒有財產Template錯誤:創建一個自定義控件擴展圖像

Cannot find the Style Property 'Template' on the type 'MyCustomImage'

我怎樣才能樣式我的自定義控制,如果圖像沒有模板屬性?

感謝

編輯: 的XAML:

<Style TargetType="{x:Type FieldComponents:MyCustomImage}"> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="{x:Type FieldComponents:MyCustomImage}"> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</style> 
+0

你能分享你使用的xaml嗎? – Amsakanna 2010-07-08 09:13:30

+0

肯定,修改了這個問題 – 2010-07-08 10:06:00

回答

2

Image自FrameworkElement繼承直接,而不是從控制,所以它不會有一個模板屬性。如果您希望能夠對控件進行模板化,則可以從Control或UserControl繼承,並讓您的模板包含一個Image。