【发布时间】:2015-08-30 06:17:06
【问题描述】:
我正在制作一个从 ComboBox 派生的 CustomControl:
public class CBT : ComboBox
{
static CBT()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(CBT),
new FrameworkPropertyMetadata(typeof(CBT)));
}
}
我正在编辑ComboBox 的默认Style(......来自 Blend 的副本)。
所以,如果我要在 ComboBox 的 Popup 内添加一个 Button,并希望注册其 Click,我应该遵循的最佳方式是什么?
我试过了:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ui_test"
xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero2"
x:Class="ui_test.CBT">
并更改为:
public partial class CBT : ComboBox {}
但是会抛出Partial declarations of 'ui_test.CBT' must not specify different base classes的错误
请帮帮我? :) 在此先感谢:)
编辑:我不知道如何处理按钮的事件:(
【问题讨论】:
标签: wpf xaml combobox custom-controls