将ResourceDictionary分配给Combobox的子类

时间:2012-03-05 16:58:54

标签: c# wpf code-behind

我已经用

加载了一个资源
<ResourceDictionary.MergedDictionaries>
  <ResourceDictionary Source="pack://application:,,,/PresentationFramework.Classic;V4.0.0.0;31bf3856ad364e35;component/themes/classic.xaml" />
</ResourceDictionary.MergedDictionaries>

然后我实例化了一个继承自X

的类Combobox
public class X : ComboBox { }

public class MainWindow : Window {
  public MainWindow() {
    panel.Children.Add(new X()); // does NOT contain the loaded styles
    panel.Children.Add(new Combobox()); // contains the loaded styles
  }
}

如何将加载的资源分配给此类X?

由于

0 个答案:

没有答案