开发者

Routed events in silverlight 3?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜