>>>Hi,
>>>
>>>I have a textbox which binds to some underlying data. I also have an autocomplete combobox which I want to use to allow better searching than a plain combo will. However, it cannot bind to the underlying data (or at least I haven't been able to make it). So what I am trying to do is only show the autocomplete combo when the user actually clicks or moves to the textbox. Initially I make the combo invisible, then in the gotfocus of the textbox I want to hide the textbox and show the combo. I've tried this code:
>>>
>>>
private void txtCus_Number_GotFocus(object sender, RoutedEventArgs e)
>>> {
>>> this.txtCus_Number.Visibility = Visibility.Hidden;
>>> this.autoCustomers.Visibility = Visibility.Visible;
>>> this.autoCustomers.Focus();
>>>
>>> }
>>>
>>> private void autoCustomers_LostFocus(object sender, RoutedEventArgs e)
>>> {
>>> this.autoCustomers.Visibility = Visibility.Hidden;
>>> this.txtCus_Number.Visibility = Visibility.Visible;
>>>
>>> }
>>>
>>>
>>>but the textbox never gets hidden. In VFP I might put a NODEFAULT in the gotfocus code. Is there something similar in C# or should I do this a different way?
>>
>>Try Visibility.Collapsed instead. But you should be able to bind the autocomplete version. What have you tried ?
>
>This is my XAML:
>
>
<ctr:AutoComplete x:Name="autoCustomers" Grid.Row="3" Grid.Column="1"
> SelectedValuePath="cus_pk" DisplayMemberPath="cus_number"
> SelectedValue="{Binding inv_cusfk, Mode=Default}"
> PatternChanged="autoCustomers_PatternChanged"
> Delay="500" LostFocus="autoCustomers_LostFocus" />
>
>
>I am trying to show the customer number of the related customer from on the Invoice screen. inv_cusfk is the field in the invoice table (and invoice entity) that holds the primary key of the customer table/entity.
>
>The control is from here:
>
>
http://www.codeproject.com/Articles/47481/WPF-Auto-complete-Control>
>Nothing shows in the box.
>
>You've made me think a bit more and I actually set the datacontext of the control to a CustomerEntityList so I should be binding like this, shouldn't I (note the SelectedValue binding now to cus_number)?
>
>
<ctr:AutoComplete x:Name="autoCustomers" Grid.Row="3" Grid.Column="1"
> SelectedValuePath="cus_pk" DisplayMemberPath="cus_number"
> SelectedValue="{Binding cus_number, Mode=Default}"
> PatternChanged="autoCustomers_PatternChanged"
> Delay="500" LostFocus="autoCustomers_LostFocus" />
>
>
>But that doesn't work either. :(
The autocomplete control is based on the standard ComboBox so bindings should work in the same way. Checking the Output window might give a clue as to what is wrong with the binding ( e.g.
http://www.codeproject.com/Articles/244107/Debugging-WPF-data-bindings).
BTW, did Visiblity.Collapsed work ?