簡體   English   中英

打開組合框(wpf)時ComboBoxItem綁定錯誤

[英]ComboBoxItem Binding Error on opening combobox (wpf)

一旦使用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')

這是代碼:

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

}

這些綁定錯誤是無害的。 請參考以下鏈接以獲取更多信息。

解決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