WPF Tutorial: Event Bindings, TextBox Placeholder and Async Yield Return (Patreon)
Downloads
Content
WPF lecture on synchronizing UI elements in a .NET Core 7 app with event bindings, a TextBox placeholder and async yield return, with source code attached.
Note: this is an older post kept for reference. Newer apps and guides are in Legacy Archive: Older Apps, Notebooks and Guides.
Covers ObservableCollection binding to a ListBox, Dispatcher.BeginInvoke for cross-thread UI access, ObservableObject and ObservableProperty from the Community Toolkit MVVM, CallerMemberName and await Task.Delay in an async foreach loop.
https://www.youtube.com/watch?v=_sQv3WWtsNY
Source code is in attachments
0:00 Introduction to the lecture
0:52 Composing the .NET Core 7 #WPF application
1:12 Starting to design the user interface
1:44 Starting to code the PlaceHolder text feature for TextBoxes
9:05 How to do unboxing with the "as" keyword
9:28 Start the second part of the lecture. Adding a ListBox
10:20 Defining an ObservableCollection and binding to ListBox for automatic synchronization
13:12 Coding a random value generating method with thread-safe Random.Shared property
14:30 How to access UI elements from static methods in sub-threads
16:14 How to display hidden errors by enabling Common Language Runtime Exceptions in Microsoft Visual Studio
16:49 Handling "the calling thread cannot access this object because a different thread owns it error" for UI elements
17:51 How to do synchronization with Dispatcher.BeginInvoke
18:44 Starting the third part of the lecture. #Binding #UI elements to automatically notify properties
19:35 How to use #ObservableObject and #ObservableProperty of Microsoft Toolkit MVVM and Community Toolkit
23:05 How to bind UI element to ObservableProperty in XAML code
25:05 Setting #DataContext of UI element for proper binding
25:46 How to use notifyPropertyChangedEvent for automatic UI updates
28:00 How to get property change event triggering caller name automatically with CallerMemberName
32:42 #Async #Yield #Return Example
34:54 How to use Task.FromResult and await Task.Delay
36:48 How to use await keyword for an async ForEach loop
Related posts
Kohya GUI Kaggle Notebook: Free SD 1.5 & SDXL Training on Dual T4 GPUs
Kohya FLUX LoRA & Fine Tuning Research and Early Configs (Legacy)
Video & Image Upscaler Pro: STAR & SeedVR2 Movie Restoration (Legacy)
All posts in this topic: Legacy Archive: Older Apps, Notebooks and Guides · New to SECourses? Start Here: Best and Most Popular SECourses Posts