编译器和运行时不会抱怨绑定,但 Setter 永远不会在我的 AutoCompleteTextBox 中命中。
<Controls:AutoCompleteTextBox
Items="{Binding Path=DropDownValues}"
Width="200"
Grid.Column="1"
Height="30"
Tag="{Binding}"
/>
和
public partial class AutoCompleteTextBox
{
public static readonly DependencyProperty ItemsProperty =
DependencyProperty.Register(
"Items",
typeof(ItemCollection),
typeof(AutoCompleteTextBox),
new PropertyMetadata(default(ItemCollection), OnItemsPropertyChanged));
public ItemCollection Items
{
get
{
return (ItemCollection)GetValue(ItemsProperty);
}
set
{
SetValue(ItemsProperty, value); //doesn't get hit
}
}
//This is how i'm cheating since my Items is always null
private void CanvasName_Loaded(object sender, RoutedEventArgs e)
{
object obj = this.Tag;
if (obj != null)
{
CjisQueryAutoCompleteData at = obj as CjisQueryAutoCompleteData;
if (at != null)
{
//use the data...
PopDropDown(at.DropDownValues);
}
}
}
//....
}