So, here's what I've found.
To declare an ArrayList in the Window.Resources:
<l:ArrayList x:Key="telephoneTypes" />
Bind the ComboBox ItemsSource:
ItemsSource="{Binding Source={StaticResource telephoneTypes}}"
In the code behind file:
ArrayList arrlist = this.Resources["telephoneTypes"] as ArrayList;
arrlist.AddRange(this.PhoneList);
(My PhoneList is a MereMortals Business Object EntityList.)
I don't get the reason for having to create a StaticResource, I would've thought setting the ItemsSource to PhoneList should've worked.
Anyway, for anyone else who might wander down this path!
-Sid.
>OK, another hurdle to jump!
>
>I'm trying to build a window of customer phone #'s with a combobox of phone type. I can semi get this working but not 100%.
>
>What I want is a Listview of the phone #'s and a combobox next to each to specify it's type. I've created a DataTemplate for the Listview but when I try and hookup the binding for the combobox back to the PhoneTypes I can't get it to display.
>
>Here's what I've got working so far:
>
>In the Window_Loaded event - (I'm using MereMortals 3.5 Business Objects)
>
> this.cboPhoneTypes.ItemsSource = this.PhoneTypes.GetAllEntities();
>
>
>This will work if I have the XAML as follows:
>
>
> <ComboBox Grid.Row="1" x:Name="cboPhoneTypes"
> DisplayMemberPath="PhoneType"
> SelectedValuePath="PhoneTypeID"
> SelectedItem="{Binding Path=PhoneTypeID}"
> />
>
> <ListView Grid.Row="2" x:Name="lstChurchPhones" ItemTemplate="{DynamicResource PhoneTemplate}" >
> </ListView>
>
>
>The ComboBox is not wired up to the actual data record but it will at least display the PhoneType options, although I've noticed if I have the ItemsSource specified in XAML it doesn't work, only if I've got it specified in the code behind.
>
>If I move the ComboBox construct into my PhoneTemplate I no longer get any of the PhoneType options, here's the code:
>
>
> <DataTemplate x:Key="PhoneTemplate">
> <Grid>
> <Grid.ColumnDefinitions>
> <ColumnDefinition/>
> <ColumnDefinition/>
> </Grid.ColumnDefinitions>
> <Grid.RowDefinitions>
> <RowDefinition />
> <RowDefinition />
> </Grid.RowDefinitions>
>
> <scs:scsDataEntryTextBox x:Name="txtPhoneNumber" Text="{Binding Path=PhoneNumber, Mode=TwoWay, UpdateSourceTrigger=Explicit}"/>
> <ComboBox Grid.Column="1" x:Name="cboPhoneTypes"
> ItemsSource="{Binding Source=ListPhoneTypes}"
> DisplayMemberPath="PhoneType"
> SelectedValuePath="PhoneTypeID"
> SelectedItem="{Binding Path=PhoneTypeID}"
> />
> </Grid>
> </DataTemplate>
>
>
>Obviously I'm missing something in my ItemsSource binding but I can't seem to figure it out. Any help would be greatly appreciated!
>
>Thanks,
>-Sid Meyers