I am currently trying to prevent a user from inputting anything aside from numbers into a textbox.
I currently have a Textbox with a textchange event which calls a relay command. however I am not able to effect the textbox from the relay command.
I have tried directly settings the textbox.text and that has not worked, nor has trying to return the string.
Here is my code
XAML
<TextBox x:Name="TextBox"  Margin="5,5,0,0" Grid.Column="1" Grid.Row="3"  HorizontalAlignment="Left" Width="31"  ">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="TextChanged">
                            <command:EventToCommand Command="{Binding TextBoxTextChanged,Mode=TwoWay}"
                                                    CommandParameter="{Binding Path=Text, ElementName=TextBox}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </TextBox>
View Model
DaysBackTextChanged = new RelayCommand<string>(daysBackText =>
        {
            Func<string> function = () => 
            {
                if (!Regex.IsMatch(daysBackText, "[^0-9]+"))
                {
                    //return TextBox.Text;
                    return "X";
                }
                else
                {
                    return "Y";
                }
            };
        });
 
    