Passing variable with RoutedEventArgs?

前端 未结 3 1684
猫巷女王i
猫巷女王i 2020-12-16 18:52

I have the following class, and want to pass the text variable as RoutedEventArgs.

  public class CloseableTabItem : TabItem
  {
    String text;

    public         


        
3条回答
  •  不知归路
    2020-12-16 19:50

    Create a new subclass of RoutedEventArgs, add a property to it where you can store the variable to be passed and create a respective handler delegate of type void (object, YourNewEventArgs) which you then assign as the handler type of your event (which currently uses a normal RoutedEventHandler which hence only provides normal RoutedEventArgs).

    If the event then is to be raised you need to create your new event args and pass the variable to its property for that variable. How to get the value in the handler should be self-explanatory.

提交回复
热议问题