简体   繁体   English

打开组合框(wpf)时ComboBoxItem绑定错误

[英]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 一旦使用combobox.isDropDownOpen获得焦点,我就会打开组合框。我在控制台中收到以下绑定错误

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;
    }

}

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 解决WPF中无害的绑定错误: https : //weblogs.asp.net/akjoshi/resolving-un-harmful-binding-errors-in-wpf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM