I need some help with WPF binding syntax:
public class ApplicationPresenter
{
public ObservableCollection<Quotes> PriceList {get;}
}
public class WebSitePricesView
{
private IApplicationPresenter presenter
{
get { return (ApplicationPresenter)DataContext; }
}
// public ObservableCollection<Quotes> PriceList
// {
// get {return presenter.PriceList; }
}
}
This XAML works fine:
<UserControl.Resources>
<ObjectDataProvider x:Key="ApplicationPresenterDS" ObjectType="{x:Type local:ApplicationPresenter}" />
<xcdg:DataGridCollectionViewSource x:Key="price_list" Source="{Binding Path=PriceList} />
</UserControl.Resources>
<xcdg:DataGridControl ItemsSource="{Binding Source={StaticResource price_list}} />
However I don't want WebSitePricesView to expose PriceList, I want to bind the DataGridCollectionViewSource directly to ApplicationPresenter.PriceList.
This XAML doesn't bind any values to the grid. Obviously I'm doing something wrong in defining the Binding Source for price_list .....
<UserControl.Resources>
<ObjectDataProvider x:Key="ApplicationPresenterDS" ObjectType="{x:Type local:ApplicationPresenter}" />
<xcdg:DataGridCollectionViewSource x:Key="price_list" Source="{Binding Source={StaticResource ApplicationPresenterDS}, Path=PriceList />
</UserControl.Resources>
<xcdg:DataGridControl ItemsSource="{Binding Source={StaticResource price_list}} />
The debug output for the first successful binding is:
Step into: Stepping over method without symbols 'Fenix.App.App'
System.Windows.Data Warning: 52 : Created BindingExpression (hash=35059110) for Binding (hash=15586314)
System.Windows.Data Warning: 54 : Path: 'PriceList'
System.Windows.Data Warning: 56 : BindingExpression (hash=35059110): Default mode resolved to OneWay
System.Windows.Data Warning: 57 : BindingExpression (hash=35059110): Default update trigger resolved to PropertyChanged
System.Windows.Data Warning: 58 : BindingExpression (hash=35059110): Attach to Xceed.Wpf.DataGrid.DataGridCollectionViewSource.Source (hash=28137373)
System.Windows.Data Warning: 60 : BindingExpression (hash=35059110): Use Framework mentor <null>
System.Windows.Data Warning: 63 : BindingExpression (hash=35059110): Resolving source
System.Windows.Data Warning: 65 : BindingExpression (hash=35059110): Framework mentor not found
System.Windows.Data Warning: 61 : BindingExpression (hash=35059110): Resolve source deferred
System.Windows.Data Warning: 91 : BindingExpression (hash=35059110): Got InheritanceContextChanged event from DataGridCollectionViewSource (hash=28137373)
System.Windows.Data Warning: 63 : BindingExpression (hash=35059110): Resolving source
System.Windows.Data Warning: 66 : BindingExpression (hash=35059110): Found data context element: WebSitePricesXc (hash=11090012) (OK)
System.Windows.Data Warning: 67 : BindingExpression (hash=35059110): DataContext is null
System.Windows.Data Warning: 52 : Created BindingExpression (hash=53154844) for Binding (hash=52037308)
System.Windows.Data Warning: 54 : Path: ''
System.Windows.Data Warning: 56 : BindingExpression (hash=53154844): Default mode resolved to OneWay
System.Windows.Data Warning: 57 : BindingExpression (hash=53154844): Default update trigger resolved to PropertyChanged
System.Windows.Data Warning: 58 : BindingExpression (hash=53154844): Attach to Xceed.Wpf.DataGrid.DataGridControl.ItemsSource (hash=16991442)
System.Windows.Data Warning: 63 : BindingExpression (hash=53154844): Resolving source
System.Windows.Data Warning: 66 : BindingExpression (hash=53154844): Found data context element: <null> (OK)
System.Windows.Data Warning: 72 : BindingExpression (hash=53154844): Use View from DataGridCollectionViewSource (hash=28137373)
System.Windows.Data Warning: 74 : BindingExpression (hash=53154844): Activate with root item <null>
System.Windows.Data Warning: 100 : BindingExpression (hash=53154844): Replace item at level 0 with <null>, using accessor {DependencyProperty.UnsetValue}
System.Windows.Data Warning: 97 : BindingExpression (hash=53154844): GetValue at level 0 from <null> using <null>: <null>
System.Windows.Data Warning: 76 : BindingExpression (hash=53154844): TransferValue - got raw value <null>
System.Windows.Data Warning: 85 : BindingExpression (hash=53154844): TransferValue - using final value <null>
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
System.Windows.Data Warning: 63 : BindingExpression (hash=35059110): Resolving source
System.Windows.Data Warning: 66 : BindingExpression (hash=35059110): Found data context element: WebSitePricesXc (hash=11090012) (OK)
System.Windows.Data Warning: 74 : BindingExpression (hash=35059110): Activate with root item ApplicationPresenter (hash=22260412)
System.Windows.Data Warning: 104 : BindingExpression (hash=35059110): At level 0 - for ApplicationPresenter.PriceList found accessor RuntimePropertyInfo(PriceList)
System.Windows.Data Warning: 100 : BindingExpression (hash=35059110): Replace item at level 0 with ApplicationPresenter (hash=22260412), using accessor RuntimePropertyInfo(PriceList)
System.Windows.Data Warning: 97 : BindingExpression (hash=35059110): GetValue at level 0 from ApplicationPresenter (hash=22260412) using RuntimePropertyInfo(PriceList): ObservableCollection`1 (hash=40261689 Count=0)
System.Windows.Data Warning: 76 : BindingExpression (hash=35059110): TransferValue - got raw value ObservableCollection`1 (hash=40261689 Count=0)
System.Windows.Data Warning: 85 : BindingExpression (hash=35059110): TransferValue - using final value ObservableCollection`1 (hash=40261689 Count=0)
System.Windows.Data Warning: 92 : BindingExpression (hash=53154844): Got PropertyChanged event from DataGridCollectionViewSource (hash=28137373) for View
System.Windows.Data Warning: 75 : BindingExpression (hash=53154844): Deactivate
System.Windows.Data Warning: 99 : BindingExpression (hash=53154844): Replace item at level 0 with {NullDataItem}
System.Windows.Data Warning: 72 : BindingExpression (hash=53154844): Use View from DataGridCollectionViewSource (hash=28137373)
System.Windows.Data Warning: 74 : BindingExpression (hash=53154844): Activate with root item DataGridCollectionView (hash=22444475 Count=0)
System.Windows.Data Warning: 100 : BindingExpression (hash=53154844): Replace item at level 0 with DataGridCollectionView (hash=22444475 Count=0), using accessor {DependencyProperty.UnsetValue}
System.Windows.Data Warning: 97 : BindingExpression (hash=53154844): GetValue at level 0 from DataGridCollectionView (hash=22444475 Count=0) using <null>: DataGridCollectionView (hash=22444475 Count=0)
System.Windows.Data Warning: 76 : BindingExpression (hash=53154844): TransferValue - got raw value DataGridCollectionView (hash=22444475 Count=0)
System.Windows.Data Warning: 85 : BindingExpression (hash=53154844): TransferValue - using final value DataGridCollectionView (hash=22444475 Count=0)
System.Windows.Data Warning: 91 : BindingExpression (hash=35059110): Got PropertyChanged event from ApplicationPresenter (hash=22260412)
System.Windows.Data Warning: 97 : BindingExpression (hash=35059110): GetValue at level 0 from ApplicationPresenter (hash=22260412) using RuntimePropertyInfo(PriceList): ObservableCollection`1 (hash=6408547 Count=27)
System.Windows.Data Warning: 76 : BindingExpression (hash=35059110): TransferValue - got raw value ObservableCollection`1 (hash=6408547 Count=27)
System.Windows.Data Warning: 85 : BindingExpression (hash=35059110): TransferValue - using final value ObservableCollection`1 (hash=6408547 Count=27)
System.Windows.Data Warning: 92 : BindingExpression (hash=53154844): Got PropertyChanged event from DataGridCollectionViewSource (hash=28137373) for View
System.Windows.Data Warning: 75 : BindingExpression (hash=53154844): Deactivate
System.Windows.Data Warning: 99 : BindingExpression (hash=53154844): Replace item at level 0 with {NullDataItem}
System.Windows.Data Warning: 72 : BindingExpression (hash=53154844): Use View from DataGridCollectionViewSource (hash=28137373)
System.Windows.Data Warning: 74 : BindingExpression (hash=53154844): Activate with root item DataGridCollectionView (hash=61423861 Count=27)
System.Windows.Data Warning: 100 : BindingExpression (hash=53154844): Replace item at level 0 with DataGridCollectionView (hash=61423861 Count=27), using accessor {DependencyProperty.UnsetValue}
System.Windows.Data Warning: 97 : BindingExpression (hash=53154844): GetValue at level 0 from DataGridCollectionView (hash=61423861 Count=27) using <null>: DataGridCollectionView (hash=61423861 Count=27)
System.Windows.Data Warning: 76 : BindingExpression (hash=53154844): TransferValue - got raw value DataGridCollectionView (hash=61423861 Count=27)
System.Windows.Data Warning: 85 : BindingExpression (hash=53154844): TransferValue - using final value DataGridCollectionView (hash=61423861 Count=27)
The debug output for the second binding is:
Step into: Stepping over method without symbols 'Fenix.App.App'
System.Windows.Data Warning: 52 : Created BindingExpression (hash=35059110) for Binding (hash=15586314)
System.Windows.Data Warning: 54 : Path: 'PriceList'
System.Windows.Data Warning: 56 : BindingExpression (hash=35059110): Default mode resolved to OneWay
System.Windows.Data Warning: 57 : BindingExpression (hash=35059110): Default update trigger resolved to PropertyChanged
System.Windows.Data Warning: 58 : BindingExpression (hash=35059110): Attach to Xceed.Wpf.DataGrid.DataGridCollectionViewSource.Source (hash=28137373)
System.Windows.Data Warning: 63 : BindingExpression (hash=35059110): Resolving source
System.Windows.Data Warning: 66 : BindingExpression (hash=35059110): Found data context element: <null> (OK)
System.Windows.Data Warning: 73 : BindingExpression (hash=35059110): Use Data from ObjectDataProvider (hash=61302538)
System.Windows.Data Warning: 74 : BindingExpression (hash=35059110): Activate with root item ApplicationPresenter (hash=20390146)
System.Windows.Data Warning: 104 : BindingExpression (hash=35059110): At level 0 - for ApplicationPresenter.PriceList found accessor RuntimePropertyInfo(PriceList)
System.Windows.Data Warning: 100 : BindingExpression (hash=35059110): Replace item at level 0 with ApplicationPresenter (hash=20390146), using accessor RuntimePropertyInfo(PriceList)
System.Windows.Data Warning: 97 : BindingExpression (hash=35059110): GetValue at level 0 from ApplicationPresenter (hash=20390146) using RuntimePropertyInfo(PriceList): ObservableCollection`1 (hash=12781633 Count=0)
System.Windows.Data Warning: 76 : BindingExpression (hash=35059110): TransferValue - got raw value ObservableCollection`1 (hash=12781633 Count=0)
System.Windows.Data Warning: 85 : BindingExpression (hash=35059110): TransferValue - using final value ObservableCollection`1 (hash=12781633 Count=0)
System.Windows.Data Warning: 52 : Created BindingExpression (hash=12661120) for Binding (hash=31408037)
System.Windows.Data Warning: 54 : Path: ''
System.Windows.Data Warning: 56 : BindingExpression (hash=12661120): Default mode resolved to OneWay
System.Windows.Data Warning: 57 : BindingExpression (hash=12661120): Default update trigger resolved to PropertyChanged
System.Windows.Data Warning: 58 : BindingExpression (hash=12661120): Attach to Xceed.Wpf.DataGrid.DataGridControl.ItemsSource (hash=16991442)
System.Windows.Data Warning: 63 : BindingExpression (hash=12661120): Resolving source
System.Windows.Data Warning: 66 : BindingExpression (hash=12661120): Found data context element: <null> (OK)
System.Windows.Data Warning: 72 : BindingExpression (hash=12661120): Use View from DataGridCollectionViewSource (hash=28137373)
System.Windows.Data Warning: 74 : BindingExpression (hash=12661120): Activate with root item DataGridCollectionView (hash=49343907 Count=0)
System.Windows.Data Warning: 100 : BindingExpression (hash=12661120): Replace item at level 0 with DataGridCollectionView (hash=49343907 Count=0), using accessor {DependencyProperty.UnsetValue}
System.Windows.Data Warning: 97 : BindingExpression (hash=12661120): GetValue at level 0 from DataGridCollectionView (hash=49343907 Count=0) using <null>: Data``GridCollectionView (hash=49343907 Count=0)
System.Windows.Data Warning: 76 : BindingExpression (hash=12661120): TransferValue - got raw value DataGridCollectionView (hash=49343907 Count=0)
System.Windows.Data Warning: 85 : BindingExpression (hash=12661120): TransferValue - using final value DataGridCollectionView (hash=49343907 Count=0)
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll