Templates and Behavior - WPF CUSTOM CONTROLS #1

  Рет қаралды 46,672

SingletonSean

SingletonSean

Күн бұрын

Пікірлер: 71
@geektoolkit
@geektoolkit 2 жыл бұрын
OMG after years of learning WPF or trying to, this is the first explanation that made sense, was practical, and to the point. THANKYOU! Also as a fellow youtuber and dev I want to say that this video is stunning to me.....you are able to think, present, and code and you weren't stumbling saying 'um'. Just a calm presentation while working on the fly...that is so much talent that I think most people will overlook how hard that can be to do. Great job!
@SingletonSean
@SingletonSean 2 жыл бұрын
Yes! Glad you enjoyed how I... ummm... um.... presented this GeekToolkit 😁
@kylerbriskey372
@kylerbriskey372 Жыл бұрын
Awesome video. I think this is exactly what I need to create a custom reusable control to make a train dispatcher program. I’d need about 100 controls that all look exactly the same. Now I gotta figure out how to wire it when clicking.
@nikhilans1608
@nikhilans1608 4 жыл бұрын
Thank you. Just an awesome video to learn how to get started with custom controls.
@rodrGP
@rodrGP Жыл бұрын
Hey, Sean, I´m a huge fan! Thank you for your videos.
@ПолинаШипневская
@ПолинаШипневская 4 жыл бұрын
OMG THANK YOU!!!! this is exactly what i was looking for a long time
@SingletonSean
@SingletonSean 4 жыл бұрын
Hey Полина, glad I could help! Thanks for watching.
@sbasalan
@sbasalan 2 жыл бұрын
Epey ilgi cekmis bu video, tebrikler.. 👍🏻
@victorhugovaldezsoto
@victorhugovaldezsoto Жыл бұрын
Thanks for this video. I have the feeling there is a lot going on within a few lines of code - this gives the feeling of playing with a black box...but nothing a little research can clarify :). For those having issues with the Style TargetType property (You're getting an error such as "The name AnalogClock does not exist in the namespace"), make sure the xmlns:local namespace property at ResourceDictionary element is set to the project name you are working on - mine was WpfApp1, so the xmlns property goes like this: xmlns:local="clr-namespace:WpfApp1.CustomControls" After this, TargetType will be able to autocomplete to "local:AnalogClock".
@afterbunny257
@afterbunny257 4 жыл бұрын
Thank you Sean, I thick I should really take a step toward animation after watching this
@afterbunny257
@afterbunny257 4 жыл бұрын
It's just not fun enough writing wpf without animations
@SingletonSean
@SingletonSean 4 жыл бұрын
Haha, I agree WPF animations are amazing! They're simple to setup and they look really nice. No worries, I think in the VisualStates episode I do some animations :) but now that you mention it the clock hands should definitely be animated to move smoother
@parko1965
@parko1965 Жыл бұрын
This should do it: Update Timer: var timer1 = new DispatcherTimer(); timer1.Interval = new TimeSpan(0, 0, 0, 0, 1); //MilliSeconds timer1.Tick += (s, e) => UpdateClockHandAngles(); timer1.Start(); Update ClockHandAngles Method: private void UpdateClockHandAngles() { DateTime now = DateTime.Now; var totalMinutes = now.Minute + now.Second / 60.0 + now.Millisecond / 60000.0; var minuteAngle = totalMinutes * 6.0; minuteHand.RenderTransform = new RotateTransform { Angle = minuteAngle, CenterX = 0.5, CenterY = 0.5 }; var totalSeconds = now.Second + now.Millisecond / 1000.0; var secondAngle = totalSeconds * 6.0; secondHand.RenderTransform = new RotateTransform { Angle = secondAngle, CenterX = 0.5, CenterY = 0.5 }; var hourAngle = ((now.Hour % 12) * 30) + (totalMinutes / 2.0); hourHand.RenderTransform = new RotateTransform { Angle = hourAngle, CenterX = 0.5, CenterY = 0.5 }; } Also the minute and hour hands move in respect to the current time
@olivier0003
@olivier0003 Жыл бұрын
Thanks a lot! WPF isn't that easy, but you've made everything clear
@zenobiusztasak8604
@zenobiusztasak8604 4 жыл бұрын
Thank god you were born!
@SingletonSean
@SingletonSean 4 жыл бұрын
Haha thanks Zanobiusz! This is my new favorite compliment.
@igorcheglakov333
@igorcheglakov333 3 жыл бұрын
14:30 at this point I stopped the video, started to think about why did author stopp the timer, went to dispatchertimer documentation etc. Turns out it was a mistake.
@faraz-online
@faraz-online 3 жыл бұрын
No doubt a valuable rich video for sure buddy! However, in context of the same, while I am using WPF window as a UserControl's only option available in one of my projects of using the same in a VSTO Excel AddIn sure am interested in knowing if one could somehow have a Resources Dictionary type of option be availed in such a case for creating a template to be availed on multiple / all windows, where there is found no option of inserting the same in a such a project where there exists no App.xaml? Thanks again!
@josbexerr5166
@josbexerr5166 4 жыл бұрын
Excelente mIster Singleton....gracias
@SingletonSean
@SingletonSean 4 жыл бұрын
De nada, mi amigo :)
@nohopestage
@nohopestage 3 жыл бұрын
Great one. Btw, I think you didn't have to use RenderTransform for the lines. Instead of setting X properties you could have just set Y ones
@nihalbayoglu9560
@nihalbayoglu9560 Жыл бұрын
thanks😊, very useful 👏
@islamfares1477
@islamfares1477 2 жыл бұрын
Can we update the clock hands every single second using event triggers?. thanks for great tutorial and for all your help.
@mdrahbarahmedkhan
@mdrahbarahmedkhan Жыл бұрын
Hey Sean, Is there a way to create custom Datepicker which work with both Georgian and Hijri date format ?
@hezkygcs7545
@hezkygcs7545 3 жыл бұрын
Thanks for such a great tutorial! I think it would be better to mention that the generic.xaml MUST be exactly the same as you did (both file name and directories relative to the project)
@sulmamr
@sulmamr 5 жыл бұрын
Such a good tutorial! And so few subscribers! In other words: I just subscribed! ;-)
@SingletonSean
@SingletonSean 5 жыл бұрын
Micha Sulman Thank you Micha! Glad you're enjoying it. I still have some videos planned for this series too :)
@daizwap9454
@daizwap9454 4 жыл бұрын
thank you amazing episode
@quangthienbui3608
@quangthienbui3608 Жыл бұрын
I created a custom Window control with Windows 11 style. To re-use the custom control in different projects, I separate the custom control into a new class library project. But then I had an issue. The project where the custom control is used can be built successfully with no error, but the custom control does not display. Could someone please help me with this?
@fellypsantos_
@fellypsantos_ 3 жыл бұрын
amazing tutorial! right to the pont! the only problem using this code is that the custom controle are not showing up in Design Mode, only when running, any tips?
@ramakrishnamishra8179
@ramakrishnamishra8179 4 жыл бұрын
What screen recording software are you using!? it is wicked smooth!
@SingletonSean
@SingletonSean 4 жыл бұрын
OBS! I've never had any issues with it (other than accidentally recording hours of content with my mic muted...)
@ramakrishnamishra8179
@ramakrishnamishra8179 4 жыл бұрын
@@SingletonSean Ok .. OBS sometimes messes with my Nvidia card and doesn't record.. but its ok!
@kyleg6790
@kyleg6790 5 жыл бұрын
Why do I keep getting control does not exist in the namespace?
@SingletonSean
@SingletonSean 5 жыл бұрын
Hey Kyle, does the namespace auto complete when you type it in? Does IntelliSense detect the control? I have noticed WPF XAML namespaces and IntelliSense can get whacky sometimes. If you provided source code, I could investigate the issue a bit deeper. Always looking to help!
@nathanwiles2719
@nathanwiles2719 4 жыл бұрын
Huge help, thanks for the tutorial. Subbed.
@SingletonSean
@SingletonSean 4 жыл бұрын
No problem Nathan, you the man!
@FuzzyDPozzy
@FuzzyDPozzy 4 жыл бұрын
i dont understand why we use this? can you explain? where can we use this and what is helpful for us? and some ideas in what we can do with it like we can create a clock,,,
@jonas9
@jonas9 4 жыл бұрын
What?
@МаксимХавро-ч4ы
@МаксимХавро-ч4ы 4 жыл бұрын
Hi! Thank you so much for your video. It was very helpful. But still, I have one question. Following your guide, I wanted to create a Custom control "Block". Basically, it`s a rectangle which I can output on Grid. The problem is, when everything is set up, I get this message "Cannot locate resource 'customcontrols/blockstyle.xaml" in XAML designer. Can you help me please?
@МаксимХавро-ч4ы
@МаксимХавро-ч4ы 4 жыл бұрын
Finally figured that out. The problem of displaying was caused not by this message but rather by Visual Studio failing to bind my folders (with Generic.xaml) to my project. Just recreated that folder and Generic.xaml and everything worked out
@theboyofthemilenium9006
@theboyofthemilenium9006 3 жыл бұрын
Just be more specific when you write de location /nameOfProyect;component/customcontrols/blockstyle.xaml
@ivandrofly
@ivandrofly Жыл бұрын
5:48 - DefaultStyleKeyProperty 13:46 - DispatcherTimer
@solvedplus858
@solvedplus858 4 жыл бұрын
very awesome tutorial many thanks but why the custom control not showing in the design time on the window?
@solvedplus858
@solvedplus858 4 жыл бұрын
if i make some thing like progress bar, how to use dispatcher inside it (not timerdispatcher) thanks in advance
@cughudson8695
@cughudson8695 2 жыл бұрын
When I Rename Themes folder and Generic.xaml file, And the clock could not display, Is AnyOne know what happen?
@gajarubanjeyakumar7226
@gajarubanjeyakumar7226 4 жыл бұрын
Hi Sean, I wonder if you could show me how to update the time on an event outside of the custom control.Thankyou.
@SingletonSean
@SingletonSean 4 жыл бұрын
Hey Gajaruban, I could show this off. Do you specifically mean with a binding, or just with a property on the control?
@gajarubanjeyakumar7226
@gajarubanjeyakumar7226 4 жыл бұрын
@@SingletonSean Hi Sean,Thanyou. At the moment i'm developing an analog gauge for a HMI solution, wich should listen for value changed event outside of the control and update acording to the new value. I think a property is what i want.
@shahjahan12003
@shahjahan12003 4 жыл бұрын
Excellent. How can I put Hour no. 1 to 12 inside the circle?
@SingletonSean
@SingletonSean 4 жыл бұрын
Hey Mohammad, I'm sure it's possible to hack some labels around to add numbers, but I think you would be better off adding a background image to the control that has the numbers and looks like a clock. I might explore this in the future.
@fayazkolar
@fayazkolar 2 жыл бұрын
Pease Increase the font size, bcoz we are unable to see what are you typing
@gajarubanjeyakumar7226
@gajarubanjeyakumar7226 5 жыл бұрын
Hi, how can i add a popup dialog to this Analog Clock, so i can dynamically show and hide hands? I'm developing a Scada System where i want to create a custom control for a Valve, when the user click on the valve symbol, there should be a popup with Open / Close buttons. Thankyou.
@SingletonSean
@SingletonSean 5 жыл бұрын
Hello Gajaruban, first I would put the pop up dialog into a hidden grid. Then when a user clicks the valve, the pop up dialog becomes visible. You could bind the show/hide hands properties to checkboxes in the pop up. That's just a quick idea. I really appreciate the suggestion. I'm gonna start a series where I add features based on suggestions/ideas. This will be episode one.
@gajarubanjeyakumar7226
@gajarubanjeyakumar7226 5 жыл бұрын
@@SingletonSean Thanks Sean, looking forward to the Episode.
@kdowd161
@kdowd161 7 ай бұрын
Good content.... better quality audio would be nice though .
@wafabenyahia1903
@wafabenyahia1903 4 жыл бұрын
This tutorial was really useful for me ,Thanks a lot ,but i nees to add this analogclock and display it from main.cs and not from main.xaml
@SingletonSean
@SingletonSean 4 жыл бұрын
Hello Wafa, is your UI implemented in code and not XAML? It should be as simple as instantiating the new clock control and then adding it to the children of a panel control, such as a Grid, on your window.
@maikborchardt5692
@maikborchardt5692 3 жыл бұрын
Thank you so much!
@Moosa_Says
@Moosa_Says 4 жыл бұрын
I've just found your channel ! from MVVM video and I've subscribed ..most probably ill watch each wpf video of yours. Please it will be great if you can make some video-s on MVVM implementation start to finish . Basic way and using some library like Prism (soon) and please keep speed a lil slow to explain things. Thanks from Pakistan ❤
@SingletonSean
@SingletonSean 4 жыл бұрын
Hey RAO, I do have a start-to-finish MVVM tutorial on my channel ("Full Stack MVVM"). However, I will admit the series has gotten pretty long. I'm planning a much more straightforward MVVM series in the future.
@Moosa_Says
@Moosa_Says 4 жыл бұрын
@@SingletonSean I have watched that. I was asking about an updated series and also based on some framework .. a comparison or maybe do's and don'ts . that would be awesome :)
@JaymzBond
@JaymzBond 3 жыл бұрын
Why don't you just use user control ? What's the advantage here?
@SingletonSean
@SingletonSean 3 жыл бұрын
Hey Mert, good question! The main benefit to these custom controls is that they are "lookless". In other words, the behavior lives inside of the C# file and is independent of the XAML. This allows consumers to override the default Generic.xaml template and implement their own UI. On the other hand, the C# behavior and XAML UI are tied together when using a UserControl. This is usually okay. In fact, I almost always use a UserControl! The only time I prefer this custom control approach is if I am building some reusable UI component that had complex behavior, or if I am doing something hacky that wouldn't work with a UserControl (lol).
@Po_Manfred
@Po_Manfred 4 жыл бұрын
Awesome!
@SingletonSean
@SingletonSean 4 жыл бұрын
Thanks GuruPrasadh!
@ivandrofly
@ivandrofly 2 жыл бұрын
Thanks
@Hiigarawolf
@Hiigarawolf 3 жыл бұрын
Thanx!
@anatoliytkachenko7081
@anatoliytkachenko7081 2 жыл бұрын
Like for the video!
Dependency Properties - WPF CUSTOM CONTROLS #2
10:53
SingletonSean
Рет қаралды 25 М.
Creating Reusable Controls - WPF TUTORIALS
17:10
SingletonSean
Рет қаралды 32 М.
ВЛОГ ДИАНА В ТУРЦИИ
1:31:22
Lady Diana VLOG
Рет қаралды 1,2 МЛН
Война Семей - ВСЕ СЕРИИ, 1 сезон (серии 1-20)
7:40:31
Семейные Сериалы
Рет қаралды 1,6 МЛН
-5+3은 뭔가요? 📚 #shorts
0:19
5 분 Tricks
Рет қаралды 13 МЛН
C#/WPF Building Custom Controls
1:32:20
Kevin Bost
Рет қаралды 21 М.
Custom Notification in WPF || With Source Code
21:17
Code Crunch
Рет қаралды 324
Intro to WPF: Learn the basics and best practices of WPF for C#
1:10:34
WPF Custom User Control + Dependency Properties
11:12
ToskersCorner
Рет қаралды 57 М.
The Art of Code - Dylan Beattie
1:00:49
NDC Conferences
Рет қаралды 4,7 МЛН
C# WPF Tutorial - Multiple Views
20:00
ToskersCorner
Рет қаралды 167 М.
Win Video WPF Path Markup
21:10
Courses Hall
Рет қаралды 3,6 М.
This open problem taught me what topology is
27:26
3Blue1Brown
Рет қаралды 716 М.
The Only Unbreakable Law
53:25
Molly Rocket
Рет қаралды 347 М.
Setting Up Drag Drop - WPF DRAG DROP TUTORIAL #1
18:41
SingletonSean
Рет қаралды 40 М.