observablecollection

How to determine if a row in ObservableCollection<T> actually changed

蓝咒 提交于 2019-12-24 02:16:09
问题 I have an ObservableCollection private static CertOrigin_Entities db = new CertOrigin_Entities(); private static ObservableCollection ocSHIPPING_DTL; I have a WPF Datagrid that I do late binding on private void btn_SEARCH_Click(object sender, RoutedEventArgs e) { string sCI = this.txt_SEARCH.Text; var sd = (db.TBL_SHIPPING.Where(x => x.CommercialInvoiceNumber == sCI)).ToList(); if (sd.Count() > 0) { iID = (int)sd[0].SHIPPING_ID; var query = (db.v_wpf_cert_origin.Where(x => x.SHIPPING_ID ==

C# WPF Datagrid doesn't dynamically sort on data update

旧巷老猫 提交于 2019-12-24 01:27:22
问题 I'm having some trouble with my datagrid : When I update some data (from the model) it shows on my DataGrid, but if click on a header to sort the column it begins to go sideways when I update existing data. Here's 2 1 example s : If I add a new value, it doesn't appear at the end (like it does when I don't sort the datagrid) but it shows at the wrong place (same place every time). If I update an existing value, the order never changes when it needs to do so. I've seen multiple answers but

WPF ObservableCollection.Remove throws NullReferenceException

末鹿安然 提交于 2019-12-23 14:02:21
问题 The code that invokes the remove operation normally works, this is the first time that I've received the NullReferenceException. I'm trying to figure out whether I might be doing something wrong and whether the exception can be avoided to make the software more bullet proof. The, relatively, big number of System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren calls seem a bit funky too. Any help will be appreciated. OS: 6.1.7600.0 .NET: 4.0.30319.225 Stack: at System

WPF and ObservableCollection<T>

半城伤御伤魂 提交于 2019-12-23 12:52:21
问题 I have an ObservableCollection<IRuleCondition> that I want to display - the IRuleCondition interface is used by 2 different classes I want to display, a RuleCondition that simply displays one rule condition (info such as priority, property to check and so on), and a RuleConditionGroup , that can contain 2 or more RuleConditions , grouped in such a way that any of the conditions could match, or all etc. In the XAML I was wondering is there a way to display a different ListView.ItemTemplate

How yield return works in c#

泪湿孤枕 提交于 2019-12-23 12:28:39
问题 I have following piece of code. public static void main(string []args) { var intergers = GetCollection(); foreach(var val in intergers) { console.writeline(val); } } public IEnumerable<int> GetCollection() { yield return 10; var obj = new MyClass(); obj.performLargeAction(); yield return 1; var obj = new MyClass(); obj.perform(); yield return 2; console.writeline("I am finished now"); } Now, when I debug the code and see the foreach iteration, then I see that first time method executes till

FilteredList gives java.lang.ArrayIndexOutOfBoundsException on update

烂漫一生 提交于 2019-12-23 09:59:33
问题 I created a simple application to test filtered lists and their behavior when the corresponding source list changes. I'd like to test update changes also, so I created ObservableList of ObservableList s. It is faster and simpler than creating additional class like Person that have observable fields. The code looks so: ListChangeListener<ObservableList<String>> changeNotifier = new ListChangeListener<ObservableList<String>>() { @Override public void onChanged(Change<? extends ObservableList

WPF DataGrid is adding extra “ghost” row

最后都变了- 提交于 2019-12-23 09:20:26
问题 Hei, In my application i'm using DataGrid to show some data. To get everything working with threading i'm using AsyncObservableCollection as DataContext of DataGrid. When my application starts it looks for files in some folders and updates AsyncObservableCollection . Finding files is done on a separate thread: Task.Factory.StartNew(() => _cardType.InitAllOrdersCollection()) .ContinueWith((t) => ThrowEvent(), TaskContinuationOptions.None); Where all the loading logic is in

How to Bind a specific ObservableCollection item's property to a CustomControl's ControlTemplate

穿精又带淫゛_ 提交于 2019-12-23 05:12:33
问题 I have a custom control with an observable-collection of "states", sort of like a multiple-state-button. Only the necessary code is here to avoid confusion: public class MyMultiStateBtn : ItemsControl { MyMultiStateBtn() { m_states = new ObservableCollection<MyState>(); } private ObservableCollection<MyState> m_states; public System.Collections.ObjectModel.ObservableCollection<MyState> States { get { return m_states; } set { m_states = value; } } } The "MyState" class (the objets in the

How to write an observable collection to a txt file?

廉价感情. 提交于 2019-12-23 04:37:41
问题 Whats the best way to write an observable collection to a txt file? I currently have the following public ObservableCollection<Account> SavedActionList = new ObservableCollection<Account>(); using (System.IO.StreamWriter file = new System.IO.StreamWriter("SavedAccounts.txt")) { foreach (Account item in SavedActionList) { file.WriteLine(item.ToString()); //doesn't work } file.Close(); } I'm not sure why it won't write to the file. Any ideas? 回答1: You can easily just write: File.WriteAllLines(

WPF binding ObservableCollection with converter

会有一股神秘感。 提交于 2019-12-23 04:27:03
问题 I have an ObservableCollection of strings and I'm tring to bind it with converter to ListBox and show only the strings that start with some prefix. I wrote: public ObservableCollection<string> Names { get; set; } public MainWindow() { InitializeComponent(); Names= new ObservableCollection<Names>(); DataContext = this; } and the converter: class NamesListConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture