I have a custom UserControl called (for instance) MyPanel, and I want to use it in another XAML file. I would like to set a property of MyPanel, such as “Title” in the XAML file into which MyPanel is placed, as follows:
<UserControl x:Name="ContainerControl">
<local:MyPanel Title="Whatever I Want" />
</UserControl>
I would like for the “Title” property of MyPanel to then populate a TextBlock in MyPanel.
How do I set up the code and/or XAML in MyPanel to support such a property?
I’m not even sure this is considered binding, so excuse my ignorance if this is wrong.
The simplest solution I can think of is:-
MyPanel xaml :-
MyPanel.cs :-
There are other “clever” solutions but this is good enough for this requirement.