private void ReloadPostCategories() { var categories = PostApi.PostCategories.Values.ToArray(); var localizedNames = PostCategorySchemaExtensions.GetLocalizedNames(); var postCategories = new Dictionary <int, string>(categories.Length); for (var i = 0; i < categories.Length; ++i) { postCategories.Add( categories[i].Id, localizedNames[i]); } slcPostCategories.SelectionChanged -= slcPostCategories_SelectionChanged; var selectedIndex = slcPostCategories.SelectedIndex; PostCategories = new ReadOnlyDictionary <int, string>(postCategories); slcPostCategories .GetBindingExpression(ItemsControl.ItemsSourceProperty)? .UpdateTarget(); slcPostCategories.SelectedIndex = selectedIndex; slcPostCategories.SelectionChanged += slcPostCategories_SelectionChanged; }
private void ReloadPostCategories() { var localizedNames = PostCategorySchemaExtensions .GetLocalizedNames(); var postCategories = new Dictionary <int, string>( PostCategorySchemaExtensions.Categories.Length); for (var i = 0; i < PostCategorySchemaExtensions.Categories.Length; ++i) { postCategories.Add( PostCategorySchemaExtensions .Categories[i].Id, localizedNames[i]); } PostCategoriesComboBox.SelectionChanged -= PostCategoriesComboBox_SelectionChanged; var selectedIndex = PostCategoriesComboBox.SelectedIndex; PostCategories = new ReadOnlyDictionary <int, string>( postCategories); PostCategoriesComboBox .GetBindingExpression(ItemsControl.ItemsSourceProperty)? .UpdateTarget(); PostCategoriesComboBox.SelectedIndex = selectedIndex; PostCategoriesComboBox.SelectionChanged += PostCategoriesComboBox_SelectionChanged; }