Search code examples
c++wxwidgets

wxDataViewModel: What is it and how do i use it?


i read the documentation http://docs.wxwidgets.org/3.0/classwx_data_view_model.html several times but it hardly answers any questions. Maybe i'm confused as to the function of this class?

so i riddle you this:

  • Is this a View Model as we know from MVVM?
  • How do you implement a derivative?
  • How do you set data in the containing wxDataViewListCtrl?
  • Is this the right/recommended way to make a table?

Solution

  • As its name subtly hints, wxDataViewModel is indeed the model in the usual MVC design (while wxDataViewCtrl is both the view and the controller).

    You can see a couple of examples of custom models in the dataview sample.

    Notice that wxDataViewListCtrl is mostly a compatibility class made for transitioning the code using wxListCtrl to wxDataViewCtrl and it already defines its own trivial list model. I don't recommend using it unless this is exactly what you need.