Hello,
i have a extended object which contains a DataTable - Property with my datasource.
on the basis of databinding and avoidance of code behind (a impossible thing with XamDataGrid :-( ) i have set my entity business object into the datacontext property of XamDataGrid.
DataContext="{Binding Path=MaskControl.Entities[ADR_Verteiler]}"
in code behind i have a centralized method to bring out all necessary datas from DataContext.
Dim Ent As swb_MaskControl.SWBMaskControlEntity = pGetEntityContext(Grid) If Ent IsNot Nothing Then 'Grid.DataContext = Nothing
Dim bnd As New System.Windows.Data.Binding bnd.Source = Ent bnd.Path = New System.Windows.PropertyPath("DataTable.DefaultView") Grid.SetBinding(DataPresenterBase.DataSourceProperty, bnd) Grid.FieldLayoutSettings.AllowAddNew = True Grid.FieldLayoutSettings.HighlightAlternateRecords = True Dim bndReadonly As New System.Windows.Data.Binding bndReadonly.Source = Ent bndReadonly.Converter = New swb_System.Converter.BoolToOppositeNullableBoolConverter bndReadonly.Path = New System.Windows.PropertyPath("IsReadonly")
.
everything works, but i have a lot of BindingExpressions at runtime. if i set the datacontext to nothing i have no more BindingExpression errors.
i'm waiting eagerly for an update.
Thank you.
If you can provide us with the full messages of the exception, I would probably be able to tell you where the binding went wrong. The exception (the one as a title to this forum thread) means that you are trying to bind IsSpeacialRecord property of some object, which is not a Record. The rest of the exception shows which that object is. Note that in most of the cases you have to set the RelativeSource property of the Binding as well to target the correct element.
System.Windows.Data Error: 39 : BindingExpression path error: 'IsSpecialRecord' property not found on 'object' ''SWBMaskControlEntity' (HashCode=48346534)'. BindingExpression:Path=IsSpecialRecord; DataItem='SWBMaskControlEntity' (HashCode=48346534); target element is 'DataRecordPresenter' (Name=''); target property is 'NoTarget' (type 'Object')