Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Hiding control in gotfocus
Message
De
02/01/2013 12:47:32
 
 
À
02/01/2013 12:34:59
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Versions des environnements
Environment:
C# 4.0
Divers
Thread ID:
01561070
Message ID:
01561073
Vues:
54
>>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. :(
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform