I have a listbox and am populating it using a custom object with Items and Values similar to pre-WPF .NET dropdowns etc. but want to have the content values themselves in a static resource in XAML form. Took a first pass at the issue for a solution that populated the listbox from the .cs file using as a ref
To populate the listbox from XAML, I was looking in the Wrox book here on p. 326 -- in the downloaded code for chapter 18 both Persons examples use a single instance ( albeit a very entertaining one ) not a multiple as in the shaded example "Classes in Code" ). Here's what I am trying at the moment: I have a SortabilityListBoxData class with fields SortabilityTypeID ( like value ) and SortabilityTypeName ( like displayabile name ) . In the XAML I have :
<x:Array x:Key="m_sortabilityListBoxItems" Type="local:SortabilityListBoxData" >
<local:SortabilityListBoxData SortabilityTypeID="S" SortabilityTypeName="Sortable"/>
<local:SortabilityListBoxData SortabilityTypeID="N" SortabilityTypeName="Non-Sortable"/>
<local:SortabilityListBoxData SortabilityTypeID="O" SortabilityTypeName="Oversized"/>
</Window.Resources> at the top of the xaml and then inside the cs
SortabilityListBoxData m_sortabilityListBoxItems; for the local variable.
Was thinking of adding
lbxSortability.ItemsSource = m_sortabilityListBoxItems; in the cs but it does not compute.
Do you have a plural Persons example that uses similar technique, say adding names like Paul Allen and Ozzie to the list?