✅ How do you control which WPF property is the default for that class?

Examine the following XAML:
<SomeClass>
PropertyValue
</SomeClass>
<OtherClass>
<OtherClass.Property>
PropertyValue
</OtherClass.Property>
</OtherClass>
<SomeClass>
PropertyValue
</SomeClass>
<OtherClass>
<OtherClass.Property>
PropertyValue
</OtherClass.Property>
</OtherClass>
If SomeClass where derived from System.Windows.Controls.Control, the property being set would be Content. But in other WPF classes, it might be something like Text. How do I specify my class's default property? The only thing I can find is for Windows Forms. Google happily found results for the default value, but I don't need that. I want the second example in the source above to resemble the first. In this case, I am deriving from System.Windows.Controls.UserControl, but as an abstract class. I don't want the derived class setting Content as that would mess up the base class.
2 Replies
nohopestage
nohopestage13mo ago
ContentPropertyAttribute Class (System.Windows.Markup)
Indicates which property of a type is the XAML content property. A XAML processor uses this information when processing XAML child elements of XAML representations of the attributed type.
Will Pittenger
Will PittengerOP13mo ago
Thanks.
Want results from more Discord servers?
Add your server