I have an object in code:
public class UserLogin
{
bool _IsUserLogin = false;
public bool IsUserLogin
{
get { return _IsUserLogin; }
set { _IsUserLogin = value; }
}
public UserLogin()
{
_IsUserLogin = false;
}
}
....
public static UserLogin LoginState;
.....
LoginState = new UserLogin();
And I need to set the bindings to the Button.IsEnabled property. That is, when the user is not registered yet, some buttons are disabled. How can I do that? I tried in xaml:
<Button DataContext="LoginState" IsEnabled="{Binding Path=IsUserLogin}">
but this work dos't and OutputWindow says: System.Windows.Data Error: 39: BindingExpression path error: IsUserLogin property not found on 'object'. I am also trying to set the Button.DataContext property for LoginState in code, but has a XamlParseException. I also read this [ WPF - binding in XAML to the object created in the code behind , but still cannot set the bindings.
[1]: WPF - binding in XAML to an object created in the code . Please, help!