首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用MouseLeftButtonUp发送CommanArgument

使用MouseLeftButtonUp发送CommanArgument
EN

Stack Overflow用户
提问于 2011-03-04 18:38:23
回答 1查看 136关注 0票数 0

我希望我的UIElement控件在单击时就像ASP.Net中的LinkButton一样,并在MouseLeftButtonUp上发送一个CommandArgument。我想我需要为此创建一个自定义事件,所以我创建了一个OnCommand事件,如下所示:

代码语言:javascript
复制
public delegate void OnCommand(object sender, CommandEventArgs e);

public class CommandEventArgs : EventArgs
{
    public string CommandArgument { get; set; }
}

如何将此事件添加到我的UIElement上的MouseLeftButtonUp中,并传递CommandArgument?或者,有没有其他方法可以达到LinkButton的效果?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-03-07 16:05:24

我没有想出一个自定义事件的解决方案,所以我做了一个带有CommandArgument和CommandName属性的UserControl。

代码语言:javascript
复制
   public partial class LinkButton : UserControl
{
    public string CommandArgument { get; set; }
    public string CommandName { get; set; }

    public LinkButton()
    {
        InitializeComponent();

        CommandArgument = String.Empty;
        CommandName = String.Empty;
    }

    public void AddElemnent(UIElement obj)
    {
        LayoutRoot.Children.Add(obj);
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5192627

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档