5
我正在創建自定義控件(源自Control
)並且想要爲控件定義默認主題。以前,所有我創建自定義控件,我已經使用設置默認值之間的區別DefaultStyleKey
static IntegerUpDown()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(IntegerUpDown),
new FrameworkPropertyMetadata(typeof(IntegerUpDown)));
}
與此assembly
屬性:
[assembly: ThemeInfo(ResourceDictionaryLocation.SourceAssembly,
ResourceDictionaryLocation.SourceAssembly)]
替代的方法來做到這一點(我曾在一些控件也注意到) -
public IntegerUpDown()
{
DefaultStyleKey = typeof(IntegerUpDown);
}
我想知道這兩種方法的優缺點,哪一個更喜歡?