Быстрый резюмеWPF - ObservableCollection Binding Failure - .NET 4.0
- Нет ничего показать в моей сетке в GUI моего приложения
- Правильные столбцы перечислены в сетке, когда он запускает (Подобрал коллекцию тип)
- CollectionChanged событие срабатывает на ObservableCollection сетка связана с
- нет привязки ошибки в окне вывода (Персональный успешно, но не регистрирует делегата)
MyView.xaml
.
.
.
<UserControl.Resources>
<xcdg:DataGridCollectionViewSource
x:Key="items"
Source="{Binding Path=Items}"
AutoFilterMode="And" >
</xcdg:DataGridCollectionViewSource>
</UserControl.Resources>
<xcdg:DataGridControl
Name="dataGrid"
ReadOnly="True"
ItemsSource="{Binding Source={StaticResource items}}"
.
.
.
MyView.xaml.cs Конструкторы
public MyView()
{
if (!DesignerProperties.GetIsInDesignMode(this))
DataContext = new MyViewModel().Tree;
initializeComponent();
}
MyViewModel.cs ключевые части
public MyTree Tree { get; set; }
public MyViewModel()
{
Tree = new MyTree();
}
MyTree.cs ключ ра ртс
public ObservableCollection<Item> Items{ get; private set; }
public MyTree()
{
Items= new ObservableCollection<Item>();
Items.CollectionChanged += delegate { Console.WriteLine("Trigger"); };
}
Trigger печатается на каждом добавление и удаление, но интерфейс по-прежнему считает, что коллекция пуста и не в курсе обновлений. Без моего дополнительного делегата Items.CollectionChanged
является null
(т.е. разобранное Xaml не вызывает слушателю быть добавлен в коллекцию)
- Что я делаю неправильно в попытке связать мой
DataGridCollectionViewSource
к ObservableCollection?
С удовольствием дайте более подробную информацию, я попытался отвлечься от своего прецедента до тех из них, что касались всего этого. Вложение коллекции может показаться смешным, но в основном это коллекция узлов в дереве для более быстрого доступа.
Заранее благодарен!
EDIT
Добавляя PresentationTraceSources.TraceLevel=High
к моему Xaml я получил некоторые более детализированный вывод.
ItemsSource="{Binding Source={StaticResource orders}, PresentationTraceSources.TraceLevel=High}"
Здесь я думаю, что проблема в том, что Default update trigger resolved to PropertyChanged
где я ожидал бы по умолчанию будет CollectionChanged
. Я все еще не уверен, что делать с этим.
BindingExpression (hash=43320496): Default mode resolved to OneWay
BindingExpression (hash=43320496): Default update trigger resolved to PropertyChanged
BindingExpression (hash=43320496): Attach to Xceed.Wpf.DataGrid.DataGridControl.ItemsSource (hash=9150720)
BindingExpression (hash=43320496): Resolving source
BindingExpression (hash=43320496): Found data context element: <null> (OK)
BindingExpression (hash=43320496): Use View from DataGridCollectionViewSource (hash=9026257)
BindingExpression (hash=43320496): Activate with root item <null>
BindingExpression (hash=43320496): Replace item at level 0 with <null>, using accessor {DependencyProperty.UnsetValue}
BindingExpression (hash=43320496): GetValue at level 0 from <null> using <null>: <null>
BindingExpression (hash=43320496): TransferValue - got raw value <null>
BindingExpression (hash=43320496): TransferValue - using final value <null>
BindingExpression (hash=43320496): Got PropertyChanged event from DataGridCollectionViewSource (hash=9026257) for View
BindingExpression (hash=43320496): Deactivate
BindingExpression (hash=43320496): Replace item at level 0 with {NullDataItem}
BindingExpression (hash=43320496): Use View from DataGridCollectionViewSource (hash=9026257)
BindingExpression (hash=43320496): Activate with root item DataGridCollectionView (hash=54545236 Count=0)
BindingExpression (hash=43320496): Replace item at level 0 with DataGridCollectionView (hash=54545236 Count=0), using accessor {DependencyProperty.UnsetValue}
BindingExpression (hash=43320496): GetValue at level 0 from DataGridCollectionView (hash=54545236 Count=0) using <null>: DataGridCollectionView (hash=54545236 Count=0)
BindingExpression (hash=43320496): TransferValue - got raw value DataGridCollectionView (hash=54545236 Count=0)
BindingExpression (hash=43320496): TransferValue - using final value DataGridCollectionView (hash=54545236 Count=0)
Не забудьте прокомментировать некоторые ответы? – VVS 2010-11-29 21:21:01