Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Binding enabled property to another control's value
Message
De
31/08/2009 07:28:53
 
 
À
29/08/2009 20:21:35
Mike Sue-Ping
Cambridge, Ontario, Canada
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Divers
Thread ID:
01421698
Message ID:
01421825
Vues:
33
>I've seen WPF demos where the property of a control is bound to the value of another control. For example there could be a textblock where its content's fontsize is controlled by a slider on the same form. Move the slider left and the textblock's content shrinks. Move the slider right and the text grows larger. Pretty straight forward and cool since no code is involved short of the actual XAML.
>
>I came a video that showed how a button's enabled state was conditional depending of if a textbox had any value. If it had any text, the button was enabled. If the textbox was empty the button was disabled. The thing that surprised me was the fact that the button's state was being set in code!! It was not bound to the textbox. Is there no way to do what I've described without code (and using binding)?

Hi,
Out of the box you can't do this since you are attempting to bind a bool value (Button.IsEnabled) to a string value (TextBox.Text).
The usual solution is to write a string to bool value converter to take care of this.
HTH,
Viv
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform