XAML代码例如以下:


相关的事件处理器代码例如以下所看到的:

private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
    if (string.IsNullOrEmpty(this.NameTextBox.Text) == true) e.CanExecute = false;
    else e.CanExecute = true;
}

private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
{
    string name = this.NameTextBox.Text;
    if (e.Parameter.ToString() == "Teacher")
    {
        this.NewItemListBox.Items.Add(string.Format("New Teacher: {0}, 学而不厌,诲人不倦。", name));
    }
    else if (e.Parameter.ToString() == "Student")
    {
        this.NewItemListBox.Items.Add(string.Format("New Student: {0},好好学习,天天向上。", name));
    }
}



相关文章:

  • 2022-12-23
  • 2021-10-10
  • 2022-12-23
  • 2021-07-04
  • 2021-09-10
  • 2022-12-23
猜你喜欢
  • 2021-06-10
  • 2021-09-20
  • 2021-09-07
  • 2022-12-23
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案