AutoCompleteBox SelectedItem Binding

Jan 11, 2011 at 7:48 PM
Edited Jan 11, 2011 at 8:29 PM

I was playing with getting the AutoCompleteBox up in running in 4.0

However... it looks like the code has some issues that were not resolved when this project died.

The one I'm running into is that SelectedItem does not get reevaluated after the ValueMemberPath or ValueMemberBinding gets set. 

So you end up with the Class.ToString() result in the text box.

I tried these:

 

        public Binding ValueMemberBinding
{
get
{
return _valueBindingEvaluator != null ? _valueBindingEvaluator.ValueBinding : null;
}
set
{
_valueBindingEvaluator = new BindingEvaluator(value);
if (SelectedItem != null)
{
string text = _valueBindingEvaluator.GetDynamicValue(SelectedItem);
//string text = FormatValue(SelectedItem);
//OnSelectedItemChanged(SelectedItem);
}
}
}

But text always returns as null, despite value looking like a good binding and Selected item having the correct path for the binding. (It appears to work once the control is fully initialized.)

I'm thinking the binding evaluator, may not be fully initialized?  Anyone have any ideas?

Also... Anyone using this class? Any other major issues I should be aware of?

I'm trying to decide if I should go ahead and fix it, or just go back to using my own class.

Edit:

OK... it does appear to not be fully initialized, this works:

 

this.Dispatcher.BeginInvoke(DispatcherPriority.Input,
                            new ThreadStart(delegate()
                            {
 OnSelectedItemChanged(SelectedItem); }));

I would think there is a more appropriate place to put this code?

And even more important, I'm still looking for feedback on:

Also... Anyone using this class? Any other major issues I should be aware of?