Reusable Controls and Data Template Selectors in Xamarin.Forms & .NET MAUI

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ส.ค. 2024
  • Stop copy and pasting around XAML all over your Xamarin.Forms and .NET MAUI apps and start reusable controls, templates, cells, and component. You can easily create reusable controls inside of ListView, CollectionView, and about anything with an ItemTemplate. You can use these controls anywhere else in your app.
    I also cover how to use Data Template Selectors inside of ListView and CollectionView to have dynamic items and controls when scrolling through a list.
    👕 Buy some swag! - jamesmontemagno.myspreadshop....
    Chapters
    00:00 - Introduction & app overview
    03:25 - Refactoring reusable components
    09:45 - What is a data template selector?
    11:00 - Creating a data template selector class
    14:00 - XAML data templates and implementation
    18:20 - Wrap-up
    Disclaimer: This channel, videos, and streams are created in my spare time and are a product of me... James Montemagno! They are NOT officially affiliated or endorsed by Microsoft (my employer) in any way. Opinions and views are my own.
    Links:
    * Source Code: github.com/jamesmontemagno/my...
    * Reusable Controls: docs.microsoft.com/xamarin/xa...
    * Data Templates: docs.microsoft.com/xamarin/xa...
    * XAML Styler - github.com/Xavalon/XamlStyler
    * Xamarin.Forms 101: • Xamarin & Xamarin.Form...
    * .NET MAUI 101: • .NET MAUI
    ☕️ Buy me a coffee - www.buymeacoffee.com/jamesmon...
    Follow:
    👨‍💻 GitHub: github.com/jamesmontemagno
    🦜 Twitter: / jamesmontemagno
    🔴 Twitch: / jamesmontemagno
    📄 Website: www.montemagno.com
    📰 Newsletter: newsletter.montemagno.com/
    What is on my hat? It is the CLE clothing logo because I am from Cleveland! Checkout their awesome CLE merch: cleclothingco.myshopify.com/
    What is that art on my wall? It is an original piece from the French street artist Gregos of La Butte Montmartre: / bcez1onhiqx
    My Setup:
    🎙 Blue Spark Microphone - amzn.to/3qgtYkq
    🎙 Blue Pop Filter - amzn.to/3jEWM3r
    🤳 Rode Microphone Arm - amzn.to/2Z68AlE
    🎧 Sony MDR7306 Headphones - amzn.to/372jxta
    📲 Stream Deck - amzn.to/373Uk1n
    📹 Elgato Cam Link - amzn.to/3a9eGbh
    📷 GoPro Hero - amzn.to/374lm90
    🖱 MX Master 2S Mouse - amzn.to/3d7J2gj
    ⌨️ Tecware Phantom Keyboard - amzn.to/3aUP4y9
    #XamarinForms #DotNetMAUI #Components
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 35

  • @rodrigomaximilianobellusci8860
    @rodrigomaximilianobellusci8860 2 ปีที่แล้ว +1

    Great video James! Thanks a lot

  • @anandshindey
    @anandshindey 2 ปีที่แล้ว

    Very helpful video. Thanks James.

  • @jeffm3865
    @jeffm3865 2 ปีที่แล้ว

    Thanks. I needed this one!

  • @oscarestrada4509
    @oscarestrada4509 ปีที่แล้ว

    Thank you! this helped me out alot!

  • @LordErnie
    @LordErnie 2 ปีที่แล้ว +2

    A really helpfull video, worth my like and the full 5 stars if I could give em. Keep it up Mr Montemagno!

  • @cliffshivkar9948
    @cliffshivkar9948 2 ปีที่แล้ว +1

    Hi Man! Great stuff as always! Thanks a lot. Please do something on the Picker control using MVVM and calling a function/form on Item Selection.

  • @Shahan85
    @Shahan85 2 ปีที่แล้ว

    Powli

  • @ademineshat
    @ademineshat ปีที่แล้ว +1

    Where can I find the playlist for the coffe app , he said series, where is that?

  • @phoenixwyllow
    @phoenixwyllow 2 ปีที่แล้ว +5

    Another great video, James!
    I do have a question, maybe I'm missing something obvious: what about a reusable control with a data template? eg. refactoring the CollectionView with its styles, layout and commands to be reusable, but providing a specific Data Template implementation on each Page.
    I know how to reuse Styles (thank you again), just I don't want to rewrite RefreshView...CollectionView...CollectionView.EmptyView when only the Data Binding (and View Model) has changed. Either my brain is being obtuse and I'm not understanding Control Templates or my google-fu is lacking.

    • @user-vm7nq8xh1c
      @user-vm7nq8xh1c 8 หลายเดือนก่อน

      Have you figured something out, I am trying to do something similar to this - render a new template based on the output of a single value

  • @jonasex3001
    @jonasex3001 2 ปีที่แล้ว +1

    Hi James, I've been watching your videos lately and enjoying a lot! I'm more from the backend stuff, but you got me interested into this playground 😁
    Who would you recommend for ASP stuff? Cheers!

    • @JamesMontemagno
      @JamesMontemagno  2 ปีที่แล้ว +2

      I would checkout th-cam.com/users/Elfocrash and th-cam.com/users/IAmTimCorey

    • @jonasex3001
      @jonasex3001 2 ปีที่แล้ว

      @@JamesMontemagno awesome, thanks!

  • @user-yp4wd7dr2h
    @user-yp4wd7dr2h 10 หลายเดือนก่อน

    @JamesMontemagno
    Hello ty for videos.
    i need httpclient operations in my control. where should i make it ?
    Should i create a controlviewmodel and bind it to control or something else ?

  • @efexzium
    @efexzium 2 ปีที่แล้ว

    How can you process the model inside the container view ? If you call it from xaml ?

  • @Cassius609
    @Cassius609 2 ปีที่แล้ว

    Where does that 'toolkit' namespace come from? (xct)

  • @yobofunk5689
    @yobofunk5689 2 ปีที่แล้ว

    Isn't there a way to not use selector if the classes in the list are different?

  • @efexzium
    @efexzium 2 ปีที่แล้ว

    cant get this to work on xamarin forms 2019

  • @timahrentlov1413
    @timahrentlov1413 2 ปีที่แล้ว +1

    Using the dynamic content of list items to select a datatemplate for a recycled list can get you into trouble. It used to be bad practice and I suspect it still is. The general advice was to have different VM types and serve up different datatemplates based on these different types.

    • @hexoter
      @hexoter 2 ปีที่แล้ว

      I have a problem with datatemplate selector , i so jitter

  • @Asasaslik
    @Asasaslik 2 ปีที่แล้ว

    12:25 - What is the name of the setting with the gray hint?

    • @JamesMontemagno
      @JamesMontemagno  2 ปีที่แล้ว +1

      That is IntelliCode in Visual Studio 2022!

    • @Asasaslik
      @Asasaslik 2 ปีที่แล้ว

      @@JamesMontemagno Thank you from Russia!!!
      The best man of the world

  • @williamprogramer4168
    @williamprogramer4168 2 ปีที่แล้ว

    ⭐⭐⭐⭐⭐

  • @yevheniytymchishin8401
    @yevheniytymchishin8401 2 ปีที่แล้ว +1

    6:30 - you can just remove the inheritance in the code-behind file, that will allow you to modify the root type of your xaml without caring about code-behind.

  • @brutis888
    @brutis888 2 ปีที่แล้ว +1

    4:58 - Link us, please :D

    • @brutis888
      @brutis888 2 ปีที่แล้ว

      The YT bots keep deleting any links I provide to XAML Styler or PrimoDev23's 2022 temporary build :/

    • @JamesMontemagno
      @JamesMontemagno  2 ปีที่แล้ว

      Added into the links github.com/Xavalon/XamlStyler

    • @brutis888
      @brutis888 2 ปีที่แล้ว

      @@JamesMontemagno Thanks!

  • @deepvibeslyrics5171
    @deepvibeslyrics5171 ปีที่แล้ว

    you have course bro

  • @cristisandu678
    @cristisandu678 2 ปีที่แล้ว

    😯😯😯😯😯

  • @efexzium
    @efexzium 2 ปีที่แล้ว

    Thanks, it would be great if we could just use HTML & CSS because XAML is verbose...