I’m new to WFP and try to learn it via different examples.
Right now I want to create a custom user control, which have button inside it (among other controls). I want to expose Buttons Content property as User Controls own.
User Control:
<DockPanel LastChildFill="True">
<Button Name="ClickButton" DockPanel.Dock="Right" Focusable="False"/>
<TextBox Name="TextBox">lorem ipsum dolor set amet</TextBox>
</DockPanel>
I want to change Buttons Content in Main Application window, like that:
<my:ButtonTextBox Name="mtb1" Grid.Column="0" Grid.Row="0">Some text</my:ButtonTextBox>
there Some text, is the text to be written over button…
How can I achieve that?
Thanks!
Your UserControl should define its own dependency property for the button content:
Then bind your UserControl’s Button to that property:
Then you can consume it as follows:
If you want to be able to do this:
you will need to specify the ContentPropertyAttribute on your UserControl: