0

I have a Custom UIElement I created below.

class ClickItem : UIElement
{
    public ClickItem()
    {

    }

    public ClickItem(Color color)
    {
        this.Color = color;
        Ellipse _e = new Ellipse();
        _e.Fill = new SolidColorBrush(this.Color);
        _e.StrokeThickness = 1;
        _e.Stroke = Brushes.Black;
        _e.Width = 10;
        _e.Height = 10;
        this.Plotter = _e;
    }

    public Point CenterPoint { get; set; }
    public Ellipse Plotter { get; set; }
    public Color Color { get; set; }
}

How do I make the Plotter Ellipse the visual for the UIElement so when I add a ClickItem to a canvas, the `Plotter' shows up.

Canvas canvas = new Canvas();
ClickItem clickItem = new ClickItem(Colors.Red);
canvas.Add(clickItem);

I can do this but I don't know how to get the ClickItem from this if I click on it.

canvas.Add(clickItem.Plotter);

1 Answer 1

1

I think you should inherit from user control, or some other relevant lower class, and add the ellipse as a child of your ClickItem.

Sign up to request clarification or add additional context in comments.

1 Comment

Well that just make too much sence. Time to take a break, I've been working too long and this was too simple. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.