2
我期望做的是公开包含在自定义控件中的按钮的单击事件。此自定义控件的实例在另一个自定义控件的控件模板中声明。公开在另一个自定义控件的控件模板中定义的自定义控件事件
例如,说我有以下几点:
public class CustomTabPanel : Panel
{
public Button newButton;
//lots of other stuff
}
然后,我有像这样
public class CustomControl : Selector
{
//stuff here
}
另一个控制这CustomControl类在generic.xaml定义模板定义的实例的CustomTabPanel像这样(东西已被删除)
<Style TargetType="{x:Type local:CustomControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:CustomControl}">
<local:CustomTabPanel IsItemsHost="True"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
一个实例然后可以在MainWindow.xaml或任何地方创建此控件。
我的问题是,如何在MainWindow.xaml中的CustomTabPanel中访问Button的Click事件,假设控件在那里定义?
我试着保持这个解释尽可能简单,如果你需要更多的实现细节请询问。
非常感谢您的帮助!
Kris