I have an issue with creating custom controls in wpf. I always intend to create custom controls completely in code-behind in case I need to extend them.
The issue is when I add them in the xaml they are editable. I don't know how to explain but when I click on them, I can write into them. I think it's the way I'm writing my custom controls. Here's a sample code.
public class MyCustomControl : UserControl
{
public MyCustomControl()
{
var button = new Button();
this.Content = button; // I always assign the root element to the Content property of the UserControl. I think this is the case
}
}
As I said when I add MyCustomControl in Xaml part, it works totally fine but when I click on it (again in xaml part) it is editable and I can write into it. What's my problem exactly?
[Edit] I added screen shots

this is the code-behind
public class MyCustomControl : UserControl
{
public MyCustomControl()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.Content = new Grid() { Background = Brushes.Red };
}
}