C# WPF Tutorial #13 - ObservableCollection with ListView

Поделиться
HTML-код
  • Опубликовано: 7 июн 2024
  • Learning how to use ObservableCollection as the ListView's Item source, allowing us to use a single collection in our code and have the UI update itself automatically when the list is updated!
    Happy Coding!
    Chapters:
    0:00 Setup
    0:54 ItemsSource Property Binding
    1:24 ObservableCollection
    3:52 Adding to the Collection
    4:22 Deleting from the Collection
    7:06 Clearing the Collection
    7:22 Recap
    7:44 Next Up
  • НаукаНаука

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

  • @Jayammo2
    @Jayammo2 Год назад +15

    This was the best WPF Tutorial series I ever watched. Everything was so easy to follow.

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

      Thanks so much, I'm really glad to hear that! I have a lot more topics to cover, let me know if you have any questions or suggestions!

    • @Jayammo2
      @Jayammo2 Год назад +1

      @@KampaPlays Um yeah I think a Navigation video would be great.

    • @KampaPlays
      @KampaPlays  Год назад +1

      @@Jayammo2 Great idea, I will work this in, thanks!

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

      Fully agree. I did not finish the tutorial and it is the best playlist by far

  • @berkefekeskin9172
    @berkefekeskin9172 3 месяца назад +2

    Using debugger effectively helps a lot for learning, thank you a lot!

  • @user-tl2nf3oc8m
    @user-tl2nf3oc8m Год назад +2

    This whole serie is amazing. Keep up the good work!

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

      Thank you so much!! Lots more to do!

  • @wookyumkim4669
    @wookyumkim4669 Год назад +3

    🤩🤩 Yes!! This is what I wanted to know! You always present the core stuff concisely! It seems that I can apply this lesson to my toy project which has DataGrid with ItemSource. The logic and principle may be same with List. ☺☺ Thank you very much as always!! 😄😄

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

      Thank you!! You can use List as an ItemSource binding with DataGrid but it will not automatically notify on all collection operations like an ObservableCollection will. You can use ObservableCollection with DataGrid, though!

  • @user-fh3sr2lr2x
    @user-fh3sr2lr2x 8 месяцев назад +1

    You did good job~~! You raised me up in C# world.

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

      Awesome to hear, thank you.

  • @yeyulchoi6314
    @yeyulchoi6314 Год назад +1

    BEST Videos! Thank you. They really help!!

  • @webdesignsbytom
    @webdesignsbytom Год назад +1

    really great series, dont stop

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

      Thank you, still more to come!

  • @Jayammo2
    @Jayammo2 Год назад +5

    Thanks!

    • @KampaPlays
      @KampaPlays  Год назад +2

      Wow, thank you so much! Really appreciate that.

  • @davidjennings6293
    @davidjennings6293 4 месяца назад +1

    Love your videos. So far the clearest explanation of data binding, ObservableCollections, etc. that I have found.
    In this exercise, is there a disadvantage to initializing the collection when it is declared (instead of in the constructor)?
    private ObservableCollection entries = new();

    • @KampaPlays
      @KampaPlays  4 месяца назад +1

      Thank you so much, I really appreciate that!
      In this case, I don't think there are any real disadvantages to doing that. Basically either way, you are creating the collection on class instantiation (generally its safe to assume the constructor will run first, anyway). I do this occasionally, depending on the object's purpose/scope.
      I wouldn't get into a habit of always or blindly initializing in the declaration though, because often times you will end up creating objects well before you need them, spending memory unnecessarily, and increasing the time it takes to create your class. Creating the objects when you need them (lazy initialization) can increase performance a good bit at scale.
      Hope this helps!

  • @h_kings
    @h_kings 16 дней назад

    Don't you think about to make a course for Udemy? I'm not english speaker but can understand and you make it so easy to learn the concepts.
    Btw, thanks so much for this videos!

  • @motivationguru7155
    @motivationguru7155 7 месяцев назад +1

    Thanks for the video. Really helpful. I have a question here we are using binding but we are taking text box entry (That we are adding on button click)from GUI i.e., It we are not running independently right. Please correct me if i am wrong.

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

      Correct - trying to sprinkle in a bit of functionality over time as to not overwhelm -- developing the UI truly independently would use all bindings, and likely incorporate the MVVM pattern in doing so.

  • @Nbveh01
    @Nbveh01 5 месяцев назад +1

    thanks

  • @El_kammex
    @El_kammex 6 месяцев назад +1

    I am programing in React a lot and there we have useState hook. UseState automaticlly refresh your view when it has been changed. Obsevarble collection I understand works similar. Correct me if I think wrong.

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

      Yes! I didn't do any React until I had already worked in WPF, and I thought the same thing when I saw UseState!

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

    I checked like 3 times that I did it exactly as you, but my ListView stays empty after manually adding items `Entries.Add("Test")` in the Constructor of the binding class.

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

      Hm. Make sure you have set your datacontext, InitializeComponent is called first, and double check your spelling/capitalization on your binding. These are common things that might be your issue.

  • @fooballers7883
    @fooballers7883 8 месяцев назад +1

    Thank you....