XAML data binding to a global variable?
c#, data-binding, silverlight, windows-phone-8, xaml
Solution
First off you can only bind to properties, so you need to add a getter and setter.
public static bool is_verifying { get; set; }
Next you can either set the `DataContext` of your form to be your class here, and bind with a simple:
"{Binding is_verifying}"
Or create a reference to your class in the resources of the form and reference it like so:
<Window.Resources>
<local:Login x:Key="LoginForm"/>
</Window.Resources>
...
<TextBox Text="{Binding Source={StaticResource LoginForm}, Path=is_verifying}"/>
Problem
How can I bind a TextBoxes Text to a global variable in my class in XAML? This is for Windows Phone by the way. Here is the code: ``` namespace Class { public partial class Login : PhoneApplicationPage { public static bool is_verifying = false; public Login() { InitializeComponent(); } private void login_button_Click(object sender, RoutedEventArgs e) { //navigate to main page NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute)); } private void show_help(object sender, EventArgs e) { is_verifying = true; } } } ``` And I want to bind a Textboxes text to "is_verifying". Thanks.