My code is here →
public class Player:INotifyPropertyChanging
{
string addressBar;
public string Url
{
get {
return addressBar;
}
set { addressBar = value; OnPropertyChanged("Url"); }
}
public Regex regVillage = new Regex(@"\?doc=\d+&sys=[a-zA-Z0-9]{2}");
RelayCommand _AddAttackTask;
public ICommand AddAttackTask
{
get {
if (_AddAttackTask == null)
{
_AddAttackTask = new RelayCommand(param =>
{
}, param => this.CanAttack);
}
return _AddAttackTask;
}
}
public Boolean CanAttack
{
get{
if (Url == null) return false;
return regVillage.IsMatch(Url);
}
}
}
On xaml, I have a text box and a button. The text field is anchored url, the button is anchored AddAttackTask. When I change the value of the text box, Url is changed. The main goal is to change the URL, the enable or disable button. But the button is always off.
I get the RelayCommand class from a WPF application with a Model-View-ViewModel design pattern
What is wrong in my code?
Fix the binding of my team!
source
share