DataForm AutoGeneratingField Trigger

Nov 18, 2010 at 12:12 AM
Edited Nov 18, 2010 at 12:23 AM
Hello,

Could you please explain why DataForm_AutoGeneratingField function defined in ViewModel is never called using the XAML below?
               
                 <dataFormToolkit:DataForm x:Name="dataForm" AutoGenerateFields="True" CurrentItem="{Binding SelectedItem}">
                 <i:Interaction.Triggers>
                 <i:EventTrigger EventName="AutoGeneratingField" SourceObject="{Binding ElementName=dataForm}">
                
                                        <cal:ActionMessage MethodName="DataForm_AutoGeneratingField">
 						<cal:Parameter Value="$eventArgs" />
 					</cal:ActionMessage>

                 </i:EventTrigger>
                 </i:Interaction.Triggers>

                </dataFormToolkit:DataForm>

              public void DataForm_AutoGeneratingField(object sender, DataFormAutoGeneratingFieldEventArgs e)
         {
}

 

Thank you,

 

Andreas

Coordinator
Nov 18, 2010 at 2:11 AM

My guess would be that there is a parameter count mismatch. Your action defines one parameter and your method has two.

Nov 18, 2010 at 8:18 AM

Rob, thank you for your answer.

This is right , so i have tried also:

 

                                        <cal:ActionMessage MethodName="DataForm_AutoGeneratingField">
                                               <cal:Parameter Value="$source" />
 						<cal:Parameter Value="$eventArgs" />
 					</cal:ActionMessage>

With no results either. However, when dataform displays it is in edit mode. Altering a property enables Cancel button. When Cancel is pressed 
DataForm_AutoGeneratingField is called in the ViewModel. But this is not what i expected the method had to be called during the construction of dataform. This is strange...

A
Coordinator
Nov 18, 2010 at 1:01 PM

If that event is called before Loaded, then it won't fire. My guess, based on your description, that that is the case. You might just want to wire the event in code-behind and forward the handling of it on to the ViewModel from there.