Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Binding to a lost focus event

$
0
0

I have a data template that defines a "textbox" control.

  <DataTemplate DataType="{x:Type ctlDefs:myTextBox}">

<Textbox  Grid.Column="1"
                     Margin="0,0,0,5"                     HorizontalAlignment="Stretch"                     VerticalAlignment="Center"                     Visibility ="{Binding ControlVisibility}"                     IsEnabled="{Binding IsEnabled}"                     MaxLength="{Binding MaxLength}"                     />
    </DataTemplate>

This textbox definition get added to the screen dynamically based on a configuration (dynamic form).  Everything is running fine.  I would like to have my  "myTextBoxDef" be able to handle the LostFocus event for the textbox that was "created" for it.  What is the best way to handle this?  I don't have a code-behind for each textbox.  I would like to add something like "LostFocus = '{Binding MyLostFocusHandler}'.  Is there a straight forward way to bind an method on the ViewModel to the Xaml?


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>