开发者

How to add a Click event to an Ellipse in code behind?

To add a click event to a Button in C# co开发者_StackOverflow社区de behind, I can do this

Button btn = new Button;
btn.Click += btn_Click;

What if I have an Ellipse, which does not contain a Click?

Ellipse e = new Ellipse;
e.??? += e_Click;


One way to do that is make button an ellipse and attatch .Click Event handler.

<Button>
    <Button.Template>
        <ControlTemplate>
            <Ellipse .../>
        </ControlTemplate>
    </Button.Template>
</Button>


Maybe the MouseUp event will serve your purpose. Try

Ellipse ellipse = new Ellipse();
ellipse.MouseUp += ellipse_MouseUp;

private void ellipse_MouseUp(object sender, MouseButtonEventArgs e)
{
   ...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜