Recently, I realized that MVVM pattern is so useful for Silverlight application and studying how to adopt it into my project.
BTW, how to hook up the textbox\'s text
In the definition section we add:
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
If you use the TextBox, add the reference to the event we want to detect:
In the ViewModel add code for Commad:
public ICommand FilterTextChangedCommand
{
get
{
if (this._filterTextChangedCommand == null)
{
this._filterTextChangedCommand =
new RelayCommand(param => this.OnRequestFilterTextChanged());
}
return this._filterTextChangedCommand;
}
}
private void OnRequestFilterTextChanged()
{
// Add code
}
Do not forget to perform the binding text:
private string _textPrintersFilter;
public string TextPrintersFilter
{
get { return _textPrintersFilter; }
set
{
_textPrintersFilter = value;
this.RaisePropertyChange(nameof(TextPrintersFilter));
}
}