C#/WPF - Learning the DataGrid

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

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

  • @eddahlouliayoub1132
    @eddahlouliayoub1132 17 дней назад

    Thanks Kevin, you really help me a lot 💜

    • @Kitokeboo
      @Kitokeboo  17 дней назад

      @@eddahlouliayoub1132 Glad to hear it. Happy coding!

  • @Adam-ce5mq
    @Adam-ce5mq Год назад +4

    Hi Kevin, just wanted to let you know I really enjoyed the video. I appreciated you not only explaining how to implement the DataGrid's various features but also what's going on under the hood, e.g. needing to create a style that targets a TextBlock in standard mode but one which targets a TextBox in editing mode.

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

      Thank you for your kind words. Happy coding

  • @willgordon5737
    @willgordon5737 4 месяца назад +2

    Dude just went GODMODE on DataGrid. Now that's what I'm talking about! Thank you!

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

      @@willgordon5737 Glad it was helpful. Happy coding

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

    Hi, Kevin! Many thanks! It was very informative.

    • @Kitokeboo
      @Kitokeboo  4 месяца назад

      @@MyAutist Glad it helped. Happy coding!

  • @Ayman-d6g1o
    @Ayman-d6g1o 17 дней назад

    Hi, i would like to know how i can change it so when i click on a cell the editMode doesnt immediately start the EditMode but rather gets selected and only on a double click it gets edited

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

    Thanks!
    You made this video.

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

    Great video. Thanks.
    Can you please explain how to use DataGrid events with MVVM.

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

      Good question. At its most basic, you can simply leverage your code behind file (*.xaml.cs) to handle generic events and invoke methods on your view model. A common misconception is that you should not use the code behind file. This is incorrect; the code behind file is perfectly acceptable for performing View logic. Business logic should not be put here, but code that is dealing directly with the view is perfectly fine. So it is perfectly acceptable to use it to handle DataGrid events.
      Depending on the specifics you will find information online where people show using alternate techniques, using Attached Properties, Behaviors, or EventTriggers. These are all fine as well.

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

      @@Kitokeboo highly appreciated. Thanks a lot.

  • @joegopher9280
    @joegopher9280 10 месяцев назад +1

    Extremely helpful!

    • @Kitokeboo
      @Kitokeboo  10 месяцев назад +1

      Glad to hear it. Happy coding!

  • @NAngelGr
    @NAngelGr 11 месяцев назад +1

    Hi Kevin, again this is a precious tutorial re: DataGrid!! I am wondering if you could please teach us on how to call a Community MVVM Toolkit WM's RelayCommand (eg EditUser) when the user DoubleClicks in a row and especially if the user rightclicks in a row and a ContextMenu with "Edit" and "Delete" items popup. It is easy to do that if you make use of the code behind but I find it to be rather impossible to be done directly without the use of it? I drove crazy with all these bindings and I have given up You are my one and only hope as even in StackOverflow I could not find someone that could really help. Also please be aware that I would like all of them to happen when the user double or right clicks ONLY within a row and NOT anywhere else within the datagrid.
    Of course this could be the theme of anohter short youtube video. And I say "short video" because I am sure that for you this could be a piece of cake Thanx mate and keep on helping us

  • @paulakwakernaak2056
    @paulakwakernaak2056 11 месяцев назад

    What about changing the background of the header based on the IsReadOnly property of the cell?

    • @Kitokeboo
      @Kitokeboo  11 месяцев назад

      This was a great question, so I made a video response. ruclips.net/video/qhAHPf7xRdI/видео.html

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

    Hi Kevin, thanks for the video I learnt a lot. I'm struggling to find a way to make the DataGridComboBoxColumn commit changes immediately after selection however, I have a second DataGridComboBoxColumn that is dependent on the selected item in the first. Any pointers?

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

      That is a good question. If you are using the SelectedValueBinding you should just need to change the mode of the binding to be PropertyChanged rather than its default. Something like this: SelectedValueBinding="{Binding Food, UpdateSourceTrigger=PropertyChanged}"

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

    UI becomes laggy after just 50 rows and 10 columns, is there any way to make wpf datagrid fast?, there is option in syncfusion datagrid to "EnableDataVirtualization" and its working, but in wpf any virtualization option is not working

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

      I might need a bit more context on what you have setup. There are several conditions that can disable virtualization (see Displaying Large DataSets here: learn.microsoft.com/en-us/dotnet/desktop/wpf/advanced/optimizing-performance-controls?view=netframeworkdesktop-4.8&WT.mc_id=DT-MVP-5003472).
      A few key things to check (my preferred way is with Snoop). On your DataGrid, ScrollViewer.CanContentScroll must be True. VirtualizingPanel.IsVirtualizing must be True. DataGrid.EnableRowVirtualization should be True. DataGrid.EnableColumnVirtualization should be True.

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

    How can i display many-to-many relational data in a DataGrid

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

      It will sort of depends on the context of your application. There is not a good built-in cell type for holding a collection of things. You will likely end up in the template based column.
      If we imagine a DataGrid of businesses, with a many-to-many relationship with customers. One possible option could show all of the customer names in the view version of the cell, and in the edit version to display all of the customers in a list. Obviously, this will have issues as the number of customers grows. At that point you are likely looking to display the list in a popup or similar.
      Happy coding.

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

    Where can I find your code? Thanks for the video.

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

      Unfortunately, it looks like I failed to push this code anywhere and my system has been cleaned since doing this stream, so I think the original copy has been lost.

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

      @@Kitokeboo Oh, thanks anyway. I had issues with "DataGridComboBoxColumn" and ended just avoiding the binding and writing it in xaml. I think that I will use Electron for the next project...

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

    At the 50+ minute mark you talk about the need for the Model and ViewModel to be seperate entities. A few of us have been discussing this same subject. You say that as soon as you have to start adding stuff to your Model for the View, you should wrap it in a ViewModel... I was thinking that when you create the ViewModel for the Model, that you can pass the Model in as a parameter of the ViewModel Constructor. Using Reflection you can match properties in the Model to properties in the ViewModel and pass on the values from the Model to the ViewModel... Would you also recommend having a private field in the ViewModel that represents the Model. I hope that makes sense.

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

      I think a lot depends on your domain and what you are doing. But yes, I think it certainly does make sense for VMs that are essentially representing models. For example, in my SimplyBudget application, I typically store the Primary Key with the view model (but I would have no objection to storing the entire model). You can seen one example of that here: github.com/Keboo/SimplyBudget/blob/main/SimplyBudgetDesktop/ViewModels/AccountViewModel.cs

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

    Bless you saaarr!

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

      Thanks! Happy coding

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

    wow!

  • @ErcanMutlu-r4x
    @ErcanMutlu-r4x 4 месяца назад

    PLEASE GUYS DO NOT USE 3rd PARTY software to explain software. WE ARE JUST LEANING,
    MAKE TUTORIALS SIMPLE. I MEAN SIMPLE MEANS JUST DRUG AND DROP DataGrid AND START TUTORIAL.
    WE DO NOT WANNA SHITTY PLUGUNS MVVMM STAUFF.. WE ARE JUST BEGINNER