Download the System.Windows.Interactivity.dll file and introduce it into the project (as you can see in the reference list of the VS project).
Using the DLL in XAML
Xmlns:i= "Clr-namespace:system.windows.interactivity;assembly=system.windows.interactivity"
<!--get focus, lose focus event for TextBox control -<TextBoxText= "Test"> <i:interaction. Triggers> <I:eventtriggerEventName= "LostFocus"> <i:invokecommandactionCommand="{Binding Relativesource={relativesource ancestortype=window},path=datacontext.ontextlostfocus}"CommandParameter="{Binding Relativesource={relativesource mode=findancestor, ancestorlevel=1, Ancestortype={x:type TextBox}}} "/> </I:eventtrigger> <I:eventtriggerEventName= "GotFocus"> <i:invokecommandactionCommand="{Binding Relativesource={relativesource ancestortype=window},path=datacontext.ontextgotfocus}"CommandParameter="{Binding Relativesource={relativesource mode=findancestor, ancestorlevel=1, Ancestortype={x:type TextBox}}} "/> </I:eventtrigger> </i:interaction. Triggers></TextBox>
Because System.Windows.Interactivity's smart hints are not supported in VS, it is often important to check which methods the EventTrigger can trigger, all EventName The list is as follows:
- MSDN in Grid Events https://msdn.microsoft.com/en-us/library/system.windows.controls.grid_events (v=vs.110). aspx
"Wpf/waf" uses System.Windows.Interactivity interactive events