Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I am unable to figure out what I am doing wrong. i have the following code in my model.
C#
private ObservableCollection<string> _metadataFieldList = new ObservableCollection<string>();
        public ObservableCollection<string> MetadaFieldList
        {
            get { return _metadataFieldList; }
            set
            {
                _metadataFieldList = value;
            }
        }

The following code in the viewmodel
C#
List<string> lst = new DirectoryInfo(fullFolderPath).GetDirectories("*", SearchOption.AllDirectories)
                .Select(x => x.FullName).ToList();

            model.MetadaFieldList = new ObservableCollection<string>(lst);


and the following in my xaml markup.
XML
<DataGridTemplateColumn Width="Auto">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <ComboBox SelectedValue="{Binding Path=FieldName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                                ItemsSource="{Binding Path=MetadaFieldList}">
                            </ComboBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

The combobox is always empty and and the ItemsSource is null.

Thanks in advance for any help.

Zafar
Posted
Updated 16-Jul-14 22:23pm
v2
Comments
ashok rathod 17-Jul-14 4:49am    
I think you have to add binding in code behind as well.

1 solution

Had to Change the ItemSource as follows
XML
ItemsSource="{Binding DataContext.TaxonomyList, Mode=TwoWay, 
           RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, UpdateSourceTrigger=PropertyChanged}"
 
Share this answer
 
Comments
Ronny_jair 20-Jan-15 11:04am    
The solution posed not understand, I came to fix?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900