inotifypropertychanged

Silverlight MVVM, stop SelectionChanged triggering in response to ItemsSource reset

ぐ巨炮叔叔 提交于 2020-01-02 23:11:08
问题 I have two ComboBoxes, A & B, each bound to an Observable Collection. Each has a SelectionChanged trigger is attached which is intended to catch when the user changes a selection. The trigger passes the selection to a Command. The collections implement INotifyPropertyChanged in that, in the Setter of each, an NotifyPropertyChanged event is fired. This is needed (in the MVVM approach) to notify the UI (the View) that the ComboBox's contents have changed. The two ComboBoxes are interdependent -

Observe PropertyChanged on items in an ObservableCollection using System.Reactive

ぐ巨炮叔叔 提交于 2020-01-02 18:04:45
问题 I have: public class Vm { private ObservableCollection<Thing> _things; public ObservableCollection<Thing> Things { get { return _things ?? (_things = new ObservableCollection<Thing>()); } } } And public class Thing :INotifyPropertyChanged { private string _value; public string Value { get { return _value; } set { if (value == _value) return; _value = value; OnPropertyChanged(); } } public event PropertyChangedEventHandler PropertyChanged; [NotifyPropertyChangedInvocator] protected virtual

Observe PropertyChanged on items in an ObservableCollection using System.Reactive

随声附和 提交于 2020-01-02 18:04:41
问题 I have: public class Vm { private ObservableCollection<Thing> _things; public ObservableCollection<Thing> Things { get { return _things ?? (_things = new ObservableCollection<Thing>()); } } } And public class Thing :INotifyPropertyChanged { private string _value; public string Value { get { return _value; } set { if (value == _value) return; _value = value; OnPropertyChanged(); } } public event PropertyChangedEventHandler PropertyChanged; [NotifyPropertyChangedInvocator] protected virtual

WPF Notify PropertyChanged for a Get Property

霸气de小男生 提交于 2020-01-02 05:22:38
问题 I have the INotifyPropertyChanged implemented using CallerMemberName public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } So this could be called in the setter of any property as - OnPropertyChanged() which would notify property changed event whenever it is being set. This is not the case for a

Is it possible to implement Property Changed as Attribute?

[亡魂溺海] 提交于 2019-12-31 01:54:05
问题 I have found an implementation of Propperty Changed Event, where i can Call Property changed without the Name of the Property in the web. And then i have build a Extension Method with it wich is here public static void OnPropertyChanged(this INotifyPropertyChanged iNotifyPropertyChanged, string propertyName = null) { if (propertyName == null) propertyName = new StackTrace().GetFrame(1).GetMethod().Name.Replace("set_", ""); FieldInfo field = iNotifyPropertyChanged.GetType().GetField(

Handling PropertyChanged in a type-safe way

旧街凉风 提交于 2019-12-30 04:32:05
问题 There have been plenty of articles about how to use reflection and LINQ to raise PropertyChanged events in a type-safe way, without using strings. But is there any way to consume PropertyChanged events in a type-safe manner? Currently, I'm doing this void model_PropertyChanged(object sender, PropertyChangedEventArgs e) { switch (e.PropertyName) { case "Property1": ... case "Property2": ... .... } } Is there any way to avoid hard-coding strings in a switch statement to handle the different

WPF INotifyPropertyChanged for linked read-only properties

百般思念 提交于 2019-12-30 03:17:09
问题 I am trying to understand how to update the UI if I have a read-only property that is dependent on another property, so that changes to one property update both UI elements (in this case a textbox and a read-only textbox. For example: public class raz : INotifyPropertyChanged { int _foo; public int foo { get { return _foo; } set { _foo = value; onPropertyChanged(this, "foo"); } } public int bar { get { return foo*foo; } } public raz() { } public event PropertyChangedEventHandler

ObservableCollection<T> in Winforms and possible alternatives

社会主义新天地 提交于 2019-12-29 07:16:52
问题 Winforms .net 3.5 app. In my app I have a generic class that looks like so: public class FilterItem { public FilterItem() { } public string FilterProperty { get; set; } public bool FilterPropertyChecked { get; set; } public ComparitiveOperator FilterOperator { get; set; } public string FilterValue { get; set; } } and I use it in all of my dialog boxes when I want to implement some sort of filter functionality. So I call the dialog form with a pre-poulated List<FilterItem> passed in the

INotifyPropertyChanged or INotifyCollectionChanged with DataTable?

柔情痞子 提交于 2019-12-29 01:14:49
问题 Hi i am having some troube with DataTables. So What i need is to detect whenever i change any cell in the DataGrid of the DataTable that is binded. How to do it? With INotifyPropertyChanged or with INotifyCollectionChanged ? Note: I am trying with INotifyPropertyChanged but it only detects when i set some value in the DataTable, and never when i change any value of any cell in the DataGrid, i already have tried OneWay and TwoWay but nothing happens. Thanks in advance! 回答1: The datagrid would

INotifyPropertyChanged and calculated property

天大地大妈咪最大 提交于 2019-12-28 16:02:09
问题 Suppose I have simple class Order, that have a TotalPrice calculated property, which can be bound to WPF UI public class Order : INotifyPropertyChanged { public decimal ItemPrice { get { return this.itemPrice; } set { this.itemPrice = value; this.RaisePropertyChanged("ItemPrice"); this.RaisePropertyChanged("TotalPrice"); } } public int Quantity { get { return this.quantity; } set { this.quantity= value; this.RaisePropertyChanged("Quantity"); this.RaisePropertyChanged("TotalPrice"); } } public