English 中文(简体)
解释另一个自定义控件的控制模板中所定义的自定义控制事件
原标题:Expose Custom Control Event that is defined in the Control Template of another Custom Control

我所要做的是曝光自定义控件中包含的按钮的点击事件。 这种自定义控件的例子在另一个自定义控件的控制模板中声明 。

例如,说我有以下内容:

public class CustomTabPanel : Panel
{
    public Button newButton;
    //lots of other stuff
}

然后我又有了一样的控制器

public class CustomControl : Selector
{
    //stuff here
}

此自定义控制类有一个以通用. xaml 定义的模板, 该模板定义了类似自定义TabPanel 的例子( 已经删除了 )

<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的自定义塔布板块中访问按钮的点击事件?

我试图尽量简单解释这个解释, 如果您需要更多执行细节, 请询问 。

非常感谢你们的帮助!

基数

问题回答

Expose it as a dependency property on the CustomControl. Wire it up in your CustomControl code file. It s kinda leveraging it.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签