I'm a bit in a mess with how to set a Dependency Property for Custom Control.
I created Custom Control, so it derives from Control class.
public class CustControl : Control
{
static CustControl()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(CustControl), new FrameworkPropertyMetadata(typeof(CustControl)));
}
}
In order to set Dependency Property I have to register it inside a class which must be derived from DependencyObject. So it should be another class:
class CustClass : DependencyObject
{
public readonly static DependencyProperty MyFirstProperty = DependencyProperty.Register("MyFirst", typeof(string), typeof(CustControl), new PropertyMetadata(""));
public string MyFirst
{
get { return (string)GetValue(MyFirstProperty); }
set { SetValue(MyFirstProperty, value); }
}
}
How now I could set MyFirst property as dependency property for CustControl?