本文整理汇总了C#中System.Windows.Documents.List.SingleOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# List.SingleOrDefault方法的具体用法?C# List.SingleOrDefault怎么用?C# List.SingleOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.List
的用法示例。
在下文中一共展示了List.SingleOrDefault方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnNavigatedTo
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
var storage = IsolatedStorageSettings.ApplicationSettings;
var languages = new List<LanguageModel>();
languages.Add(new LanguageModel("Danish", "http://da.wikipedia.org"));
languages.Add(new LanguageModel("English", "http://en.wikipedia.org"));
languages.Add(new LanguageModel("Norwegian", "http://no.wikipedia.org"));
languages.Add(new LanguageModel("Swedish", "http://sv.wikipedia.org"));
languageListPicker.ItemsSource = languages;
if (storage.Contains("setting_language"))
{
var language = storage["setting_language"] as LanguageModel;
if (language != null)
{
var listLanguage = languages.SingleOrDefault(l => l.Name == language.Name);
if (listLanguage != null)
languageListPicker.SelectedItem = listLanguage;
}
}
}
示例2: LoginButton_Click
private async void LoginButton_Click(object sender, RoutedEventArgs e)
{
string username = UserNameTextBox.Text;
string password = PasswordTextBox.Password;
//username = "amila";
//password = "0774461890";
try
{
userList = EmployeeService.GetLoggedEmployeeByUserNamePassword(username, password);
if (userList.Count() == 1)
{
Session.LoggedEmployee = userList.SingleOrDefault();
Session.Account_Type = userList.SingleOrDefault().ACCOUNT_TYPE;
Session.EmployeeID = userList.SingleOrDefault().EMP_ID;
MainWindow.Instance.Show();
ShouldClose = true;
this.Close();
}
else
{
await this.ShowMessageAsync("Login Error", "Please check your username and password", MessageDialogStyle.Affirmative);
UserNameTextBox.Clear();
PasswordTextBox.Clear();
}
}
catch (Exception ex)
{
capturedException=ex;
}
if (capturedException != null)
{
await this.ShowMessageAsync("Login Error", capturedException.Message.ToString(), MessageDialogStyle.Affirmative);
}
}