8
創建樣式時,是否可以將ControlTemplate屬性設置爲以前定義的資源?舉例來說,如果我有在ResourceDictionary中以下內容:WPF - 在樣式中使用ControlTemplate資源
<ControlTemplate x:Key="MyControlTemplate" TargetType="{x:Type Button}">
...
</ControlTemplate>
再後來想在這樣的方式來使用它:
<Style x:Key="MyStyle" TargetType="{x:Type Button}">
<Setter Property="Template" Value="???"/>
</Style>
這可能嗎?
最重要的部分是模板必須樣式之前定義。否則它是_XamlParseException:找不到具有名稱/密鑰的資源YourTemplateKey_ – 2014-01-22 12:35:58