Saturday, 17 August 2013

Bind a Command to UserControl's Loaded event

Bind a Command to UserControl's Loaded event

I have a user control which has a dedicated view model associated with it.
I want to raise a command which is defined in the respective view model
whenever Loaded event of my user control fires.
But my command never gets fired, not even once.
Here is the code
<views:BaseUserControl
x:Class="Finance.MainUI.Views.UserControls.SelectCustomerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:userControl="clr-namespace:Finance.MainUI.Views.BaseControls"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:views="clr-namespace:Finance.MainUI.Views"
d:DesignHeight="300" d:DesignWidth="300">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<i:InvokeCommandAction Command="{Binding
EditCommand}"></i:InvokeCommandAction>
</i:EventTrigger>
</i:Interaction.Triggers>
<Grid>
Other controls
</Grid>
</views>

No comments:

Post a Comment