Custom Control
Create a new project, Add a new item and then select user control.
Then go to MyUserControl1.xaml and add textblock and image from toolbox.

Now we want to give the control to the user using our custom control, so he/she can change text and image. For that go to MyUserControl1.xaml.cs and add a dependency property of type as of the 'text' property of textblock i.e string. In this case set metadata to 'null'.

Do the same for source of the image of the type 'ImageSource'.

Now bind the respected properties with our dependency properties so they can be changed by the user,

Now we can use our created custom control anywhere we like. And can change the text or image source to add any image.

Like this we can give the desired control over our custom control to the user by binding them with our created dependency properties.


Now we want to give the control to the user using our custom control, so he/she can change text and image. For that go to MyUserControl1.xaml.cs and add a dependency property of type as of the 'text' property of textblock i.e string. In this case set metadata to 'null'.

Do the same for source of the image of the type 'ImageSource'.

Now bind the respected properties with our dependency properties so they can be changed by the user,

Now we can use our created custom control anywhere we like. And can change the text or image source to add any image.

Like this we can give the desired control over our custom control to the user by binding them with our created dependency properties.



Rade PralicaPosted May 29, 2021, 2:49 AM EDT
How to create custom control in Visual Studio 2019
Saurabh RaiPosted Apr 25, 2016, 10:10 PM EDT
Good one
Asfend YarPosted Feb 20, 2016, 11:43 PM EST
nice
Harshad PansuriyaPosted Dec 1, 2015, 6:34 PM EST
Nice one
Santhakumar MunuswamyPosted Dec 1, 2015, 6:08 AM EST
Nice share
Mukesh KumarPosted Dec 1, 2015, 3:43 AM EST
Good Job