Aditya Borde
Aditya Borde

Reputation: 1257

ComboBoxItem Binding Error on opening combobox (wpf)

I am opening my combobox once it gets focus using combobox.isDropDownOpen I am getting the following binding error in the console

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.ItemsControl', AncestorLevel='1''. BindingExpression:Path=VerticalContentAlignment; DataItem=null; target element is 'ComboBoxItem' (Name=''); target property is 'VerticalContentAlignment' (type 'VerticalAlignment')

here is the code:

private void combo_GotFocus(object sender, RoutedEventArgs e)
{
    placeholder.Visibility = Visibility.Collapsed;

    combo.IsDropDownOpen = true;
}

private void combo_LostFocus(object sender, RoutedEventArgs e)
{
    if (combo.Text.Equals(""))
    {
        placeholder.Visibility = Visibility.Visible;
    }

}

Upvotes: 0

Views: 137

Answers (1)

mm8
mm8

Reputation: 169400

These kind of binding errors are harmless. Please refer to the following link for more information.

Resolving harmless binding errors in WPF: https://weblogs.asp.net/akjoshi/resolving-un-harmful-binding-errors-in-wpf

Upvotes: 1

Related Questions