I have a user control and I've been doing some experimentation with handling events of various controls in the underlying view model. In many cases I have found that using some basic xaml like the bit below works.
<i:Interaction.Triggers>
<i:EventTrigger EventName="Event to be handled">
<i:InvokeCommandAction Command="{Binding Path= I Command handling event}" />
</i:EventTrigger>
</i:Interaction.Triggers>
However I have been trying this with a text box defined in my xaml like so:
<TextBox x:Name="TxtInvNumber" Margin="5" Grid.Column="1" Width="80" Text="{Binding Path=InvoiceNumber}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="TextChanged">
<i:InvokeCommandAction Command="{Binding Path=InvoiceNumberChangedCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
When done like this and with a breakpoint set on the InvoiceNumberChangedCommand nothing happens, yet if I put a simple message box in the TextChanged handler in the code behind the view it gets fired every time.
Can anyone explain if this is something particular to text boxes or is it that using interactions to handle events in this way doesn't always work?
Incidentally I had wondered if this might have had something to do with the fact that the text box text property is bound to an underlying property that implements propertychanged so I tried it with the LostFocus event as well and still the same result.
Thanks