开发者

Routed events in silverlight 3?

开发者 https://www.devze.com 2023-04-02 07:24 出处:网络
I have a Control, within a control, within a control. Like so.. QuizMaster -> Question -> Answers -> RadioButton

I have a Control, within a control, within a control.

Like so..

QuizMaster -> Question -> Answers -> RadioButton

When one of the answers is checked I want the function in Quizmaster called AskNextQues开发者_如何学运维tion() to run.

How do I do that?


You would create an event in your nested control, and have your QuizMaster subscribe to that event.

In your Answers add this:

public static event Action<bool> IsAnswered;

and Fire this event when you select a RadioButton in its handler

public void OnRadioButtonSelected(object sender, SomeEventArgs e)
{
  if(IsAnswered != null)
    IsAnswered(true);
}

and in your QuizMaster Subscribe to this static event:

public void SomeMethod()
{
  Answers.IsAnswered += new Action<bool>(Answers_IsAnsweredCompleted);
}

public void Answers_IsAnsweredCompleted(bool IsAsnwered)
{
  //call your method in QuizMaster
}
0

精彩评论

暂无评论...
验证码 换一张
取 消