T
T
theonic2015-06-27 14:48:19
Programming
theonic, 2015-06-27 14:48:19

How to create your own control?

How to create your own control based on the standard radiobutton?
I tried to create a class that inherits from radiobutton

public partial class radioTest2:RadioButton
    {
        public string note;
        public radioTest2()
        {

        }
    }

But XAML doesn't see it though
xmlns:MyNamespace="clr-namespace:projectWPF2.rcontrols;

added (the control is in a separate namespace). What to do with this, tell me, please.
I also tried to create via UserControl (another xaml file appears), but the problem remains the same.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sumor, 2015-06-27
@theonic

In theory, you are doing everything right.
1. Describe the control, it's still a UserControl or a UIControl successor.

public partial class radioTest2:RadioButton
    {
        public string note;
        public radioTest2()
        {

        }
    }

2. In the window to which you add, describe xmlns.
3. In the right place, add the control.
Small moment. If the project in which the control is located is not compiled or it has an error, then the place where the control is used is also shown with an error. It is especially unpleasant that in this case the window in the visual editor may not be displayed correctly. Just fix other errors and rebuild the solution.
In this regard, to simplify life, it is better to take out controls in a separate project.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question