Build Your Own Custom Value Converter For WPF Binding

Sdílet
Vložit
  • čas přidán 2. 07. 2024
  • What happens when the built-in value converters in WPF just aren't cutting it for you anymore?
    That's right. You need to take matters into your own hands.
    In this video tutorial, I'll show you how to make your own custom value converters using IValueConverter. Create more flexible bindings! Now you can map between different types of data on your control and your view model.
    ----
    🔑 Membership & Subscriptions:
    - 📨 Weekly Newsletter: weekly.devleader.ca
    - 🏘️ Private Discord Community: / discord
    - 📽️ CZcams Membership: / @devleader
    🧠 Courses:
    - All Courses: www.devleader.ca/courses
    - Getting Started with C#: dometrain.com/course/getting-...
    - Deep dive C#: dometrain.com/course/deep-div...
    - C# Zero to Hero BUNDLE: dometrain.com/bundle/from-zer...
    - Refactoring For C# Devs: dometrain.com/course/from-zer...
    - [FREE] Intro to Software Development: • [FREE MINI COURSE] - I...
    🗣️ Social Media & Links:
    - All My Links: linktr.ee/devleader
    - Blog: www.devleader.ca/
    - TikTok: / devleader
    - LinkedIn: / nickcosentino
    - Threads: threads.net/@dev.leader
    - Twitter: / devleaderca
    - Facebook: / devleaderca
    - Instagram: / dev.leader
    - GitHub: github.com/ncosentino/
    - Twitch: / devleaderca
    - CZcams: / @devleader
    ❤️ Affiliations & Products/Services That I Love:
    - VPS hosting from RackNerd: my.racknerd.com/aff.php?aff=9013
    - VPS hosting from Contabo: www.jdoqocy.com/click-1010286...
    - My newsletter platform ConverKit: convertkit.com/?lmref=c5X7KQ
    - My newsletter referral system SparkLoop: dash.sparkloop.app/signup?aff...
    - My AI shorts helper Opus Clip: opus.pro/?via=2f9e97
    - I try to help answer questions at Quora: www.quora.com/quoraplus?ch=10...
    - My favorite computer parts store Newegg: click.linksynergy.com/fs-bin/...
    - My favorite supplement store Bulk Supplements: glnk.io/63qn/devleader
    ----
    #dotnet #csharp #wpf #frontend

Komentáře • 5

  • @DevLeader
    @DevLeader  Před 8 dny

    💡 Learn how to program in C#:
    - dometrain.com/course/getting-started-csharp?affcode=1115529_nl-teyzg
    🧠Deep dive on C#:
    - dometrain.com/course/deep-dive-csharp?affcode=1115529_nl-teyzg
    🎁Zero to Hero C# Bundle:
    - dometrain.com/bundle/from-zero-to-hero-csharp/?affcode=1115529_nl-teyzg
    💪 Skill up your refactoring:
    - dometrain.com/course/from-zero-to-hero-refactoring-for-csharp-developers?affcode=1115529_nl-teyzg
    ✉ Subscribe to my free software engineering newsletter:
    - subscribe.devleader.ca

  • @krccmsitp2884
    @krccmsitp2884 Před 5 dny +1

    At some point I stopped writing custom ValueConverters. Instead, the ViewModels themselves provided properties with the target type to bind to.

    • @DevLeader
      @DevLeader  Před 5 dny

      @@krccmsitp2884 spoiler alert for upcoming videos: that's exactly where my career led me to as well 😁
      The concept was interesting but value converters simply never delivered long-term for us

    • @r14958
      @r14958 Před 3 dny

      @@DevLeader Doesn't this mean that the ViewModel must be very "View aware", which sounds like a MVVM no-no?

    • @DevLeader
      @DevLeader  Před 3 dny

      ​@@r14958there's a lot about mvvm I'm not a huge fan of, but the view models never know about the views ever. I just have view models that can do a transform into WPF-centric things without a converter.
      For example, I'd have a visibility property directly on the view model and not only an IsVisible. I just cut out the value converter middleman -- and no reference to the view.
      If the problem becomes "well it shouldn't need to know if it's actually Visibility or not", then in these situations I've used two tiers of view models to separate these concepts into different classes. In this case if you change your view implementation you still have a "buffer" through one more layer of abstraction.