Hi,
Ok. This is a tricky one: (for me at least)
I have a datagrid. A column of the datagrid is a simple <DataGridTemplateColumn>
with its CellTemplate containing a <DataTemplate>
which contains a <ComboBox>
<my:DataGrid Name="dataGridMain" AutoGenerateColumns="False">
<my:DataGrid.Columns>
<my:DataGridTemplateColumn Header="Food" >
<my:DataGridTemplateColumn.CellTemplate >
<DataTemplate>
<ComboBox Name="comboDataTemplate" Text="{Binding Path=Food, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding Source={StaticResource resFoodLookups}}"
DisplayMemberPath="FoodName" SelectedValuePath="FoodID" IsEditable="True" />
</DataTemplate>
</my:DataGridTemplateColumn.CellTemplate>
</my:DataGridTemplateColumn>
</my:DataGrid.Columns>
</my:DataGrid>
All is working fine.
Each combobox is bound to a static list - I know this because I told it to do so in the ItemsSource="{Binding Source={StaticResource resFoodLookups}}"
statement.
But my requirement is that this list will change from row-to-row. That is: each time a user types a new entry in the combobox list on one row, I want to have it available in the selection on the next row.
Basically, I want to create a new list for the user each time the user inserts a new word in the combobox on any of the rows. (The combobox is editable).
Now, I can wire up the "ItemsSource=..." at run-time, but I'm only able to do this once thus the <DataTemplate>
propagates the 'same' list to 'all' the comboboxes on 'all' the rows.
My thoughts are that I need to change the ItemsSource=... property on an object-by-object basis on each combobox that is created in memory after the DataTemplae has created them - but I have no idea how to do this !?!
Can anyone help or at least point me in the right direction?
Thanks... **