当前位置: 首页>>代码示例>>C#>>正文


C# List.SingleOrDefault方法代码示例

本文整理汇总了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;
                }
            }
        }
开发者ID:hallatore,项目名称:RandomWiki,代码行数:25,代码来源:Settings.xaml.cs

示例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);
            }
        }        
开发者ID:sbpallekumbura,项目名称:LoanManagementSystem,代码行数:38,代码来源:LoginWindow.xaml.cs


注:本文中的System.Windows.Documents.List.SingleOrDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。