views:

230

answers:

0

Hi there

I'm trying to databind to an ExpandoObject. I'm getting the following error:

System.Windows.Data Error: 17 : Cannot get 'Dimension2' value (type 'Object') from 'Dimensioner' (type 'ExpandoObject'). 
BindingExpression:Path=Dimensioner.Dimension2; DataItem='Bogføringslinje' (HashCode=10586695); 
target element is 'TextBlockComboBox' (Name=''); 
target property is 'SelectedItem' (type 'Object') 
InvalidOperationException:'System.InvalidOperationException: Property path is not valid. 'System.Dynamic.ExpandoObject+MetaExpando' does not have a public property named 'Dimension2'.    
    at CallSite.Target(Closure , CallSite , Object )
    at MS.Internal.Data.DynamicPropertyAccessor.GetValue(Object component)
    at MS.Internal.Data.PropertyPathWorker.GetValue(Object item, Int32 level)
    at MS.Internal.Data.PropertyPathWorker.RawValue(Int32 k)'

Bogføringslinje.Dimensioner.Dimension2 does indeed exists.. As I can print the value out, just before i create my binding..

The bindings are created with the following code:

            var binding = new Binding();            
            binding.Path = new PropertyPath("Dimensioner.Dimension" + i.ToString());
            binding.Converter = new StringToDimensionConverter(dimensioner.ElementAt(i).Key);
            binding.Mode = BindingMode.TwoWay;

            //binding.Mode = BindingMode.OneWayToSource;

            var tc = new DataGridComboBoxColumn()
            {
                Header = dimensioner.ElementAt(i).Key,
                SelectedItemBinding = binding,
                //TextBinding = binding,
                ItemsSource = dimensioner.ElementAt(i).Value

            };

            PresentationTraceSources.SetTraceLevel(tc, PresentationTraceLevel.High);

            this.BogføringslinjerDataGrid.Columns.Add(tc);

Any suggestions?