Since I moved my View inside an ItemsControl, I cannot get the EventTrigger to fire in my ViewModel. Here is my Commmand Declaration which should fire on LostFocus:
public ICommand UpdateOrdersCommand { get; set; }
public void UpdateOrders(object param)
{
UpdateFields();
}
My Container XAML:
<UserControl.Resources>
<WMS:PurchasingModel x:Key="ViewModel" />
<DataTemplate x:Key="myDataTemplate1">
<WMSViews:Purchasing1 />
</DataTemplate>
</UserControl.Resources>
<Grid x:Name="LayoutRoot"
Background="White"
DataContext="{StaticResource ViewModel}">
<ItemsControl ItemsSource="{Binding Path=ColPurchasing}"
ItemTemplate="{StaticResource myDataTemplate1}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</Grid>
My View where this EvenTrigger used to fire on LostFocus:
<Classes:TextBoxEx TabIndex="1"
x:Name="tbFoodSales"
HorizontalAlignment="Left"
Height="23"
Margin="55,79,0,0"
TextWrapping="Wrap"
VerticalAlignment="Top"
Width="61"
TextAlignment="Right"
Text="{Binding Path=FoodSales, Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="LostFocus">
<i:InvokeCommandAction Command="{Binding UpdateOrdersCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Classes:TextBoxEx>