private static void OnViewModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var comboBox = d as ComboBox;

            if (comboBox == null)
            {
                throw new NotSupportedException();
            }

            var viewModel = (CardControlViewModel)e.NewValue;
            IReferenceBookConfiguration configuration;
            var success = viewModel.AttributeFormatParser.TryParseReferenceBookConfiguration(viewModel.Attribute.Configuration, out configuration);

            if (!success)
            {
                return;
            }

            comboBox.IsReadOnly = !configuration.IsEditable;

            comboBox.DropDownOpened += (o, a) =>
            {
                ComboBoxEx.SetIsLoading(comboBox, true);
                var loader = new ReferenceBookLoader(viewModel.Repository);
                loader.Completed += (l, args) =>
                {
                    comboBox.ItemsSource = GetCollectionView(configuration.Source, args.Objects, configuration.StringFormat, configuration.ElementsTypes.ToList(), viewModel.AttributeFormatParser);
                    ComboBoxEx.SetIsLoading(comboBox, false);
                };
                loader.Load(configuration.Source);
            };
            comboBox.SelectionChanged += (o, a) =>
            {
                var selectedItem = comboBox.SelectedItem as ReferenceBookItem;
                if (selectedItem != null)
                {
                    foreach (var attribute in selectedItem.Object.Attributes)
                    {
                        if (viewModel.Attribute.Name != attribute.Key)
                        {
                            viewModel.AutoComplete.Fill(attribute.Key, attribute.Value);
                        }
                    }
                }
            };
        }