Binding failed when adding another property

I have a basic view that associates with similar ones (the backing property is of type object):

<ContentControl Content="{Binding WalletsView}"/>

Now I have added another property to the corresponding view model, namely

public SmartObservableCollection<Selectable<Type>> PriceGrabbers {get; private set;}

where SmartObservableCollectionis derived from ObservableCollectionto facilitate multi-threading updates.

Now I get a lot of binding errors (in fact, all bindings in sub view models) are triggered through the debug window), like this (I wonder if I remove the property again PriceGrabbers, all errors disappear):

System.Windows.Data error: 40: BindingExpression path error: property “OverviewHidden” was not found in 'object' '' MainWindowViewModel '(HashCode = 30986197)'. BindingExpression: Path = OverviewHidden; DataItem = 'MainWindowViewModel' (HashCode = 30986197); the target is "ColumnDefinition" (HashCode = 22768693); target - "NoTarget" (type "Object")

Thus, the binding mechanism apperently tries to find any bindings on the main model. Linking works great. Although this is normal, I would prefer that the errors go away. Have any of you already encountered this problem, and if so, how did you solve it?

+3
source share
1 answer

WPF, MEF . , ViewModel, MainWIndow, , . , , .

, .

SmartObservableCollection Action<Action>> CollectionChanged, - , , , .

Dispatcher.Invoke() Dispatcher.BeginInvoke() , .

DataContexts ViewModel :

Dispatcher.CurrentDispatcher.BeginInvoke((Action)delegate()
{
    view.DataContext = this;
});

?

hickup , Dispatcher.Invoke() Dispatcher.BeginInvoke(). ( , MainWindowViewModel), , DataContexts ViewModels.

, - WPF -. DataContext - null, , DataContext, DataContext MainWindowView, MainWindowViewModel. , , , DataContexts , , , DataContext ​​ .

0

Source: https://habr.com/ru/post/1779979/


All Articles