WPF Custom User Control + Dependency Properties
Vložit
- čas přidán 26. 07. 2024
- In this video we create a simple custom user control which acts as a spoiler button for displaying and collapsing content behind it. We also vaguely cover using dependency properties and how to implement our new custom control.
Button Style Code: pastebin.com/TqdABJKf
MainWindow.xaml: pastebin.com/M8tKwxUP
SpoilerControl.xaml: pastebin.com/H1JmChAH
SpoilerControl.cs: pastebin.com/YwtGVhEh
More Info: docs.microsoft.com/en-us/dotn...
** Tip Jar **
Paypal: toskerscorner@outlook.com
BTC: 3DkvwvcQ8Vt2U84jdtEhNBx2Ueai3Xttmu
ETH: 0xFf79A145e1ED6F538607Ec374968e605cbea758b
BCH: qqpgrnzuhc5hav4e79m8nfhmugs46jtl0ujxcu0tj5
LTC: MHXQmJA3hkwTPeArB9QPNkcLiHQx723yMb
Full Source Code: github.com/Tosker/ContactBook-Tutorial
Great tutorial with a very practical example. Great job. Thank you.
3:19 - Says "But" and types "
Great video!!! Really easy to understand.
Saved me loads of time! Cheers!
Awesome video! Thank you very much.
this is very good and simple
many thanks for your greet tutorial
This is very helpful. I didn't know about setting the Name property of the UserControl and the using the ElementName to get the property. Great job!!
excellent video
Thanks, this helped, I had everything right on my own except this one part: ElementName= when binding the property to the user control's XAML. I'm curious what the other methods were you mentioned.
When I bind the ViewModel property to the dependency property of the custom UserControl, the UI interface is not updated after the data is updated. Do you know why?
Genius
in description SpoilerControl.cs link follows to same XAML code as SpoilerControl.xaml
Sorry about that. Full source code is available here: github.com/Tosker/ContactBook-Tutorial
Hehehe thank you for the warning
thanks...much appreciated.
Q: how to make a style in the main window for the new usercontrol and the style contain the dependency properties of the usercontrol?
is it possible to create Custom usercontrol with mvvm where we should not have Dp in code behind rather in viewModel?
Actually you can, by using XAML. It's called control.template. So, e.g. create a radiobutton-style, create a control.template tag and throw in a togglebutton for instance. Voila.
What is the difference between TargetType="Button" and TargetType="{x:Type Button}"?
Virtually no difference!
Oh! Thank you then :^)
Audio?
There is audio, perhaps it is quiet for you? Seems fine for me.
Appreciate your videos, man!! Yes, the audio seems to very quite
Thanks! And sorry to hear that. Perhaps a pair of head phones or checking your settings might help.
Thank you very much for your tutorials. I think you deserve more views than what your'e getting
@@ToskersCorner I had to CRANK the volume way up as well. Good vid.
in description SpoilerControl.cs link follows to same XAML code as SpoilerControl.xaml
Sorry about that. Full source code is available here: github.com/Tosker/ContactBook-Tutorial