In specific, how do you take elements/models that are added to an XRObservableCollection and use them to generate rows/columns in XAML listbox?
I have tried to do this on my own, but my listbox remains empty, despite having elements added to my collection.
Note: This menu is being designed for a Windows Embedded Compact 7 device using VS2008 and Silverlight for Windows Embedded, so many features available in WPF do not apply to this environment.
What i have done is initialize the model of the element i want to display in the listbox as follows:
DispCh->Initialize(ChannelNum,ChannelName,InputType,DispRange_Low,DispRange_High,MovingAvgFilter,EngUnit);
By substituting values in for those variables, you are defining what to display in each column of the listbox (implying that 1 row of the listbox will contain 6 columns; display range high and low are in 1 column).
Now i add this model of my element to the collection as follows:
pMainPage->m_pDispChModelCollection->Add(DispCh);
This works fine as when i check the collection count after adding, it increases.
Now, i believe that i have done the binding correctly to take the collection and convert it into the listbox. To do this, i do the following:
XRValue value;
value.vType = VTYPE_PROPERTYBAG;
value.pPropertyBagVal = m_pDispCh_Model;
m_pReviewModeDispCh->m_pReviewMode_ChList->SetDataContext(&value);
m_pDispCh_Model->Set_ChannelCollection(m_pDispChModelCollection);
where m_pDispCh_Model
is the model class that contains all the xaml initialization and binding, m_pReviewModeDispCh
is the class definition for the XAML menu, m_pReviewMode_ChList
is the IXRPtr to the XAML listbox, and Set_ChannelCollection
takes m_pDispChModelCollection
and passes it to m_pRevChList
which is the following:
TBoundPointerProperty<IXREnumerable> m_pRevChList;
hResult = RegisterBoundProperty(L"ReviewModeDispChList", m_pRevChList);
Now, i could post the code that shows what i did for the xaml menu, the c++ code for defining the xaml class, the c++ class for the element model, and the c++ code where i use these class methods, but it wouldnt follow the MVCE, so instead, i'd like to see if the idea behind steps i am doing are correct as far as the code i have provided or at the very least if someone could point me in the right direction regarding generating listbox grids from C++ code.