XAML Data Binding and MVVM Basics (.NET MAUI, WPF, UWP, Xamarin.Forms)

Поделиться
HTML-код
  • Опубликовано: 28 окт 2024

Комментарии • 91

  • @waynepeters8551
    @waynepeters8551 2 года назад +15

    Fantastic idea for new videos! Data binding can definitely be a little confusing at first. But seeing the pro fix common errors is infinitely helpful to say the least. Much appreciated James!

  • @bkaankose
    @bkaankose 2 года назад +7

    One tip from my side:
    VS light bulb suggestions are enabled in XAML. So if you are looking to import some namespaces in your XAML, you can just write the name of the class and press Ctrl + . (control and dot). That will suggest you to import proper namespace into your XAML directly. Very useful for providing x:DataType for the DataTemplate and DataContext.

  • @lnagy88
    @lnagy88 2 года назад +2

    I wish that we had this video back in the day when I learned XAML the first time. Good explanation and examples for beginners!

  • @enzodiaz3921
    @enzodiaz3921 2 года назад +1

    Thanks James, a very very simple explanation that unravels the whole binding thing for those of us just starting out with xaml binding.

  • @hwod44
    @hwod44 2 года назад

    Hi James! You are exposing the Model to the View. You're breaking the MVVM principles. Thanks for your videos!

    • @JamesMontemagno
      @JamesMontemagno  2 года назад

      Maybe. As I said it is an option based on your app. I like to say you can make your own MVVM principles :)

    • @hwod44
      @hwod44 2 года назад

      @@JamesMontemagno haha! :) you look Groucho Marx

  • @ezzaldeen
    @ezzaldeen 2 года назад +2

    Every day I learned something new from James ❤️

  • @rory6315
    @rory6315 2 года назад

    You're awesome James, I hope your channel grows to the behemoth it deserves.

  • @xixixiaojie
    @xixixiaojie 2 года назад +3

    Thank you very much James, it was super helpful. I learnt alot and noted my mistakes. I'm very new to Xamarin and all so I still run into alot of problems in my code. Yea, I was trying to send it to a database and it ran successfully. Thanks a lot!

  • @WolfRose11
    @WolfRose11 2 года назад

    Definitely helpful, this is the main issue that I was having that was unclear in the Microsoft documentation.

  • @David-qz1rd
    @David-qz1rd 2 года назад +2

    Nice.. we should focus more on the basics and common mistakes!

  • @GuildOfCalamity
    @GuildOfCalamity 2 года назад +1

    Great video! Would like to see you do a deep dive on RelativeSource AncestorType and RelativeSource AncestorLevel.

  • @microdesigns2000
    @microdesigns2000 2 года назад

    I'm just here to say how much I appreciate the pachinko machine!

  • @Tamer_Ali
    @Tamer_Ali 2 года назад

    Thanks James,
    someone of our colleagues was asking for the same topic 2 days ago on Twitch. 👍

  • @matomarkovic6765
    @matomarkovic6765 2 года назад

    Good Job on this. Really easy explained on how it works. A lot videos go in deep explaining and losing the simpicity. Thanks :)

  • @drivetrainerYT
    @drivetrainerYT 2 года назад +1

    Goldmine Channel. Subbed.

  • @ShareKnowledge76
    @ShareKnowledge76 2 года назад +1

    Excellent explanation👍

  • @giourikilinkaridis1138
    @giourikilinkaridis1138 2 года назад +1

    Amazing video!!! Straight to the point and most importantly simply explained. Could you please cover the Backgrounding subject like Long-Running-Tasks for both IOs and Android.

  • @majesticjester1
    @majesticjester1 2 года назад +1

    How do you data-bind/notifypropertychanged if there is a list inside the person model

  • @Widgets19
    @Widgets19 2 года назад +1

    Love It James.

  • @rogerio43898
    @rogerio43898 Год назад

    Muito interessante, aprendo "English" e programação ao mesmo tempo. I'm from Brasil.

  • @BinaryNexus
    @BinaryNexus 2 года назад

    Another awesome video. I would love for you to do a video on the proper way to handle secrets for open source apps and setting those secrets during deployment to the AppStore/GooglePlay using AppCenter.

    • @JamesMontemagno
      @JamesMontemagno  2 года назад

      I am learning all things GitHub actions now and may do a video on that. Checkout github.com/jamesmontemagno/app-ac-islandtracker/blob/master/appcenter-post-clone.sh for secrets in app center

  • @evedickson2496
    @evedickson2496 Год назад

    Great video... super helpful

  • @mkgungor
    @mkgungor Год назад

    I am loving it ❤

  • @rushas
    @rushas 2 года назад +1

    Great tips.
    I'm also amazed with the capability of the auto-complete. Is that regular intellisense? Because mine does not seem to be as clever as yours. Any suggestions on configuring it?

    • @JamesMontemagno
      @JamesMontemagno  2 года назад +1

      Just regular Visual Studio 2022 community edition:) nothing else

    • @rushas
      @rushas 2 года назад

      @@JamesMontemagno Then I guess I should start using 2022, instead of 2019 :)

  • @toma1385
    @toma1385 2 года назад +1

    Really good idea.

  • @FaheemRasheed
    @FaheemRasheed 2 года назад

    always waiting for your videos and always gets to learn new things. thanks james. and thank you again, for best quality practices and showing what not to do !
    please tell us as well. where can we send our code.

  • @aboubacar.traore
    @aboubacar.traore 2 года назад

    Great video, i just learned something new !

  • @efexzium
    @efexzium 2 года назад +1

    Can this work for a collection of objects that have internal properties?

  • @ishmaa6804
    @ishmaa6804 2 года назад

    Oof. I always put logic in getters/setters to update UI stuff.
    Not sure if I will use this method from now on - but now I know of it and it is awesome

  • @mdrahbarahmedkhan
    @mdrahbarahmedkhan 2 года назад

    Hi James,
    I need help.
    Actually I have an Item Control and when I populate the same with data it comes around 50-80 item in the Grid Each Item Control has button. On click of that button I wanted to open popup but that pop-up should be inside the item control area.
    Could you please help me

  • @dreamdancer8212
    @dreamdancer8212 2 года назад

    Great video. Its clearing up a lot of little things for me. I wonder however whether implementing the NotifyPropertyChanged functionality into the (Domain) class Person is violating the Seperation of Concern principle? Shouldn´t dealing with the UI exclusively be done by the ViewModel? Or did you not regard the Person class as a Domain class? Or am I wrong at all with this thought and there is something I didn´t understand?

    • @JamesMontemagno
      @JamesMontemagno  2 года назад

      I think it is up to you. You may have a list of people in a ListView and then be updating their properties and want the UI to update so that would be the main way of doing it. I don't think it is an issue personally. It is still separated and if no one is listening then it doesn't hurt anyone :)

    • @dreamdancer8212
      @dreamdancer8212 2 года назад

      @@JamesMontemagno Hi James, thank you for the quick response. I guess you are right and it most likely depends on what you are trying to achieve. My Question arose from remembering working on a WPF project and trying to figure out where to put the functionality - into the Class or into the ViewModel. Both seemed to have pros and cons. And as always there don´t seem to be the one, "always right" answer. Thank you for the really helpful videos and I am eagerly waiting for the next one. :)

  • @jamesbalisciano2922
    @jamesbalisciano2922 Год назад

    6:15 Just for a more thorough understanding of the C# language, I think it's worth noting that the error message was correct. There was no firstName *property*. A variable declaration without getters and setters is a field. Fields are not properties, and the binding system works with properties.

  • @cptechno
    @cptechno Год назад

    I want to create a XAML visual component (rectangle) that will have lots of copies but with different information. Let's suppose 100 copies. I plan to use the XML Grid container to display the visual components. My question is: How can create a visual component in XAML? Can you point to possible parent classe(s)? Can I use XAML to implement the visual component? Any advice or pointers would be greatly appreciated.

  • @Adam-ce5mq
    @Adam-ce5mq 2 года назад +1

    Excellent video - really well presented and clear information! I really appreciate content where best practices are explained and coding problems solved in real-time.
    I do wonder about moving the INotifyPropertyChanged implementation to the model. I think it's been mentioned it in other comments but it does feel like UI concerns are leaking into the domain. With a simple example like the Person class in the video, where it's essentially just a POCO, I'm not sure it matters too much. But if the Person class were to grow more rich, encapsulating more person-y behaviour, as it would in a real application, then I think the INotifyPropertyChanged code starts to look more and more out of place. To be clear, I don't think this is an issue with your content, more something which seems to be an inherent quirk of the MVVM pattern.

    • @JamesMontemagno
      @JamesMontemagno  2 года назад +1

      Yeah, every app is different, but again think about the situation where you have a list of people and their properties are updating and you want to update the UI. INotifyPropertyChanged actually has nothing to do with the UI and is just an interface that people can subscribe to. Maybe i'll do a full video on it :)

    • @mamahaha7472
      @mamahaha7472 2 года назад

      @@JamesMontemagno beginers here. stuck on this problem too, hope you do a full video 🥲

    • @dyn01234567
      @dyn01234567 2 года назад

      @@JamesMontemagno I'd really appreciate a video on this! One thing that has always confused me about MVVM is how and where OnPropertyChanged() should work. I usually put it on properties in my VM, which have a backing store from a model. However, if I have a service that updates my Model, then what is the best way to push these changes to the VM? Should the model notify the VM the way the VM notifies the view?

  • @xavier.xiques
    @xavier.xiques 2 года назад

    Good video, thanks!

  • @al02525942
    @al02525942 2 года назад

    Super amazing

  • @Jad.abouzaki
    @Jad.abouzaki 2 года назад +1

    Thank you

  • @radoslavatanasov8846
    @radoslavatanasov8846 2 года назад +1

    Awesome video James! Could you show us how to notify property of PersonViewModel when some of the Person properties is change? I mean when we change Person.Firsname from the UI to change property that is in the PersonViewModel.

    • @doublebass120
      @doublebass120 2 года назад

      The Person model implements INotifyPropertyChanged ("INPC"). This interface has a PropertyChanged event, which is raised whenever you make a change to a property.
      You can add an event handler in the view model to subscribe to that event:
      Person.PropertyChanged += (s,e) => Console.WriteLine("property on person changed");

  • @turgaysenlet
    @turgaysenlet 2 года назад

    Once again, very concise and helpful video, thanks! I learned a life-long skill from a video under 20 mins :))
    I have a question about the possible React integration that is being mentioned here. Is there a good way to use React with Xamarin Forms or MAUI? I have not found any tutorials or descent-looking NuGet packages for this purpose. Do you have any pointers? Thank you

  • @frankruscil680
    @frankruscil680 2 года назад

    Any Data Binding examples for Lists within Lists? I have a collectionview that binds to a list of "Functional Areas" (a,b,c, etc.) but within each "Functional Areas" (a,b,c, etc.) I need to display a list of buttons. The "Functional Areas" and child buttons are displayed based on user permissions.

  • @eddienoureddine7408
    @eddienoureddine7408 2 года назад

    Is there a situation where we need to notify property changed for static properties ? ! if yes why does it not work with OnPropertyChanged?

  • @joshlueck1302
    @joshlueck1302 2 года назад

    Cool video. Can you do a video showing how to handle environment configurations in Xamarin/Maui. Include things like how to substitute in the plist and manifest, plus a recommended way to manage api calls. Been doing Xamarin for a few years and this seems to be absent from the documentation.

  • @BeastModeDR614
    @BeastModeDR614 2 года назад

    Any examples on how to pass data between views? Like Lists, Single Objects etc....

  • @ChrisStayte
    @ChrisStayte 2 года назад

    Good basic video.

  • @ElCidPhysics90
    @ElCidPhysics90 2 года назад

    Why did you write get => password instead of get { return password} in the additional optimization part?

  • @aboubacar.traore
    @aboubacar.traore 2 года назад

    Great video, but I wonder wouldn’t INotifyPropertyChanged cause an error if the object is used in EF as Database?

    • @JamesMontemagno
      @JamesMontemagno  2 года назад

      Shouldn’t it is a copy out of the database, you would want to save it if it was changed

  • @beelzaBob
    @beelzaBob Год назад

    Here's what's confusing to me about this: in all of Jason's tutorials, he has a page and a corresponding ViewModel. For example, MainPage would correspond with MainPageViewModel. That isn't the case here -- there's a View without a ViewModel and a ViewModel without a View (MainPage has no ViewModel, PersonPageViewModel has no View).
    I know it's not his code, but I'm surprised he didn't address this, as it's confusing the heck out of me. I'm brand-new to everything except C# here, so I know there are assumptions concerning basic understanding that I'm missing, but... I don't know how to deal with this issue.
    EDIT: I didn't see he posted the code. So, yeah, that sort of solves that.

  • @zechsd1756
    @zechsd1756 2 года назад

    Ok, maybe someone can help me out, I am wondering, cause I still kind of had problems telling the difference between ViewModel and Model. At the end of this example, the Person file would be the model and the PersonPageViewModel file would obviously be the ViewModel, am I right?

  • @weslyarfan8407
    @weslyarfan8407 2 года назад

    Hai Bro, is there any suggest from you?
    Sorry to ask you here, my Problem is, I want to export Xamarin.Forms Scrollview to Pdf.
    Please help me to reach it out.
    Thanks..

    • @JamesMontemagno
      @JamesMontemagno  2 года назад

      Do you mean you are trying to display a Pdf?

    • @achilleaskaragiannis4947
      @achilleaskaragiannis4947 2 года назад

      I have done this in WPF you first convert it to XPSand then to PDF its quite a headache but it can happen

  • @sl023
    @sl023 2 года назад

    Hello James , Need about the unit test in .NET MAUI .

    • @JamesMontemagno
      @JamesMontemagno  2 года назад

      nUinit, xUnit, and of the standard unit testing stuff would work. Checkout what the team uses github.com/dotnet/maui/tree/main/src/Core/tests

  • @mohamedzarif4473
    @mohamedzarif4473 Год назад

    good

  • @yobofunk5689
    @yobofunk5689 2 года назад +1

    [CallerMemberName] is quite nice instead of declaring every name...

    • @JamesMontemagno
      @JamesMontemagno  2 года назад

      Checkout my MVVM helpers that really simplifies all of this stuff ruclips.net/video/y8ZqEOLDeo8/видео.html

  • @richardle899
    @richardle899 2 года назад

    Please make a video of Xamarin bluetooth connection tutorial, Thank you.

  • @romekin
    @romekin 2 года назад

    yup, without a get/set its not a property but a field!

  • @prakashsza
    @prakashsza Год назад

    Please create a binding advanced video, thanks

  • @matheusguifer
    @matheusguifer 7 месяцев назад

    captions could use a review

  • @snapback9221
    @snapback9221 Год назад

    Observerpattern

  • @berto3538
    @berto3538 2 года назад

    you must have BindableBase¡¡¡

    • @JamesMontemagno
      @JamesMontemagno  2 года назад

      In MVVMHelpers I do. checkout my other videos on it.

  • @earthlingthings
    @earthlingthings 3 месяца назад

    Xaml can't bind unless default constructor in vm. That's.oftem left out of these binding tutorials. These are not real world examples.

  • @kamertonaudiophileplayer847
    @kamertonaudiophileplayer847 2 года назад

    Never keep a password with a person. Why? A password isn't an attribute of the person.

    • @JamesMontemagno
      @JamesMontemagno  2 года назад +1

      I probably wouldn’t store a password in clear text in the database is what I’m saying. I’m not a security expert but there are some best practices to follow out there.

    • @kamertonaudiophileplayer847
      @kamertonaudiophileplayer847 2 года назад

      @@JamesMontemagno So my remark is a perfect for these best practices.

  • @yaroslavpanych2067
    @yaroslavpanych2067 7 месяцев назад

    I call it "rotting of the brain" syndrome. The field "firstname" is there, and there IS a way to get or set it, just by getting or setting it. Dude has already forgot his basics. Property is a tool to achieve some specific purpose. That purpose is to control value assignment or reading. In this case, such control is not needed, so FIELDS are OK. And if some stupid library doesn't accept fields where properties are fed, that is the problem of the library.

    • @JamesMontemagno
      @JamesMontemagno  6 месяцев назад

      Yes it is totally true that you can just get and set fields. Binding generally doesn't work to fields. Most binding is based, in part, on the ComponentModel PropertyDescriptor model, which (by default) works on properties. This enables notifications, validation, etc (none of which works with fields).

  • @BeastModeDR614
    @BeastModeDR614 2 года назад

    Any examples on how to pass data between views? Like Lists, Single Objects ???