Если вы добавите ссылку на Microsoft.Expressions.Interactions.dll
(Проект-> Добавить ссылку-> Сборки-> Расширения в Visual Studio), вы можете использовать CallMethodAction
для вызова метода:
<TextBox x:Name="txtServer" Text="{Binding Server, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True}"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions">
<i:Interaction.Triggers>
<i:EventTrigger EventName="PreviewTextInput" >
<ei:CallMethodAction TargetObject="{Binding}" MethodName="IsAllowedInput" />
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
ИзКонечно, метод не может быть private
:
public void IsAllowedInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
{
//...
}