私は次のようなスタイルを持っています:
var comboBoxItemStyle = new Style(typeof(ComboBoxItem));
comboBoxItemStyle.Setters.Add(new EventSetter(ComboBoxItem.PreviewMouseDownEvent,
new MouseButtonEventHandler(OnMyComboItemMouseDown)));
comboBoxItemStyle.Setters.Add(new EventSetter(ComboBoxItem.PreviewKeyDownEvent,
new KeyEventHandler(OnMyComboItemPreviewKeyDown)));
私が次にすることはこれです:
Resources.Add(typeof(ComboBoxItem), comboBoxItemStyle);
しかし、それはすべてのコンボボックスにこのスタイルを追加します。
2つのComboBoxがあるとします。
ComboBox myComboBox = new ComboBox();
ComboBox someOneElsesComboBox = new ComboBox();
このスタイルをに適用するにはどうすればよいMyComboBox
ですか?