For example, suppose you create a userControl and your control has a button, and when the button text changes, you define an event for it. That is, you see where the button text changes and there you define an event for it.
public event TextChangedEventHandler ItemTextChanged;
public delegate void TextChangedEventHandler(object Sender);
private void btnContent_Click(object sender, RoutedEventArgs e)
{
if (ItemTextChanged != null)
{
ItemTextChanged(txtbChildBtn);
}
}
Same example with another name
public event ValueChangedEventHandler ItemValueChanged;
public delegate void ValueChangedEventHandler(object Sender);
private void btnContent_Click(object sender, RoutedEventArgs e)
{
if (ItemValueChanged != null)
{
ItemValueChanged(sender);
}
}
or FucosChanged button
public event FucosEventHandler FucosChanged;
public delegate void FucosEventHandler(object Sender, DependencyPropertyChangedEventArgs e);
private void btnContent_FocusableChanged(object sender, , DependencyPropertyChangedEventArgs e)
{
if (FucosChanged != null)
{
FucosChanged(sender, e);
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…