【发布时间】:2014-03-03 17:10:04
【问题描述】:
如何在 ViewModel 中使用 GotFocus() 和 LostFocus()?
private void TxtDescribeGroup_GotFocus(object sender, RoutedEventArgs e)
{
TxtDescribeGroup.BorderBrush = new SolidColorBrush(Colors.Orange);
}
private void TxtDescribeGroup_LostFocus(object sender, RoutedEventArgs e)
{
TxtDescribeGroup.BorderBrush = new SolidColorBrush(Colors.Gray);
}
这段代码用 Xaml.CS 编写。 但我想在 ViewModel 中编写所有代码。 有人让我知道如何在 ViewModel 中编写事件吗? 以及如何在 ViewModel 中为 ListBox 编写选择更改事件?
private void lstShow_Tap(object sender, GestureEventArgs e)
{
if (lstShow.SelectedItem != null)
{
ListBox item = (ListBox)sender;
LoginPageModel listItem = (LoginPageModel)item.SelectedItem;
MessageBox.Show("Selected FirstName==> " + listItem.FirstName);
}
}
这也是用 Xaml.Cs 编写的。如何在 ViewModel 中编写。 提前谢谢..
【问题讨论】:
标签: c# windows-phone-7 mvvm