I am working on a WPF aplication with MVVM pattern. I created a button and a textbox and binded them so when i write in the textbox and press the button, a message will with the content of the textbox will appear. Now i want to allow only hexadecimals in the textbox. Any ideeas ?
this.checkme = new SimpleCommand(this.CanCheckMe, this.IsCheckMe);//initialize commands
private Boolean IsCheckMe()//methods
{
return true;
}
private void CanCheckMe()
{
MessageBox.Show(this.Numbers);
}
private readonly SimpleCommand checkme;
private string numbers;
public String Numbers
{
get { return numbers; }
set {
if (numbers == value)
return;
this.numbers = value;
this.OnPropertyChanged(nameof(Numbers));
}
The above are the code for the button and the textbox in c# and below is the code in xaml.
<ribbon:TextBox Header="Numbers" Text="{Binding Path=Numbers, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=True}"/>
<ribbon:Button Header="Check me" Command="{Binding Path=CheckMe}"/>