inotifypropertychanged

Updating dependent property once instead of twice

元气小坏坏 提交于 2019-12-11 14:11:22
问题 In my ViewModel I have two properties type of Datetime. They are bound in XAML with TwoWay mode. When I update each of them - OnPropertyChanged raises in set part of this Datetime property for the third property. So I want to update the third property only once when I update two Datetime properties at the same time, instead of updating third property twice. How it can be archieved? Code applied: //1 public DateTime StartDate { ... set { this.selectedEndDate = value; this.OnPropertyChanged(

EventTrigger sometimes fails to fire

徘徊边缘 提交于 2019-12-11 12:09:45
问题 I'm yet again a bit stumped, and was hoping someone could please help. Apologies in advance to the long code. Issue - I have a DataTrigger that starts off firing as expected, but it eventually fails and I can't work out why. In the example provided, it moves a rectangle around a Canvas. Each click of the button moves it in this sequence; N, NE, E, SE, S, SW, W, NW. Then it starts the sequence again, starting with N. Once the first sequence is completed, it won't move North. It will only ever

INotifyPropertyChanged doesn't fire when declared in certain syntax

陌路散爱 提交于 2019-12-11 11:37:16
问题 While investigating on a seemingly unrelated issue, I've hit some unexpected binding behaviour. Having class StringRecord : INotifyPropertyChanged { public string Key {get; set; } // real INPC implementation is omitted public string Value { get; set; } // real INPC implementation is omitted ... } class Container { public ObservableKeyedCollection<string, StringRecord> Params { get; set; } ... { Now, when a TextBox is bound to one of the collection items in obvious way <TextBox Text="{Binding

Bind one property to another and chain/fire OnPropertyChanged

萝らか妹 提交于 2019-12-11 11:14:27
问题 I'm binding to properties from XAML in a WPF application, but this query is about raising 'PropertyChanged' events on one class property when another is raised in a different class/object. One use case is where a combobox ItemsSource binds to a property (PropB in my simplified example below) and that property returns a collection based on other properties (PropA below). PropB in class B needs to raise PropertyChanged when PropA in class A changes, but class A does not reference class B. Is

Binding using INotifyPropertyChanged

青春壹個敷衍的年華 提交于 2019-12-11 10:26:57
问题 In my project I wanna change the background of a Datagrid cell whenever a new Bid price comes in. And I set it using public class Notifier : INotifyPropertyChanged { public bool BidUp { get { return _bidUp; } set { _bidUp = value; OnPropertyChanged("BidUp"); } } public double Bid { get { return _bid; } set { BidUp = (value > this.Bid); _bid = value; OnPropertyChanged("Bid"); } } public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName) {

How to update a ListBox if an element was changed c#

随声附和 提交于 2019-12-11 09:59:23
问题 Hi, I'm struggling a bit using the ListBox.DataSource and the INotifyPropertyChanged Interface. I checked several posts about this issue already but I cannot figure out, how to update the view of a ListBox if an element of the bound BindingList is changed. I basically want to change the color of an IndexItem after the content has been parsed. Here the relevant calls in my form: btn_indexAddItem.Click += new EventHandler(btn_indexAddItem_Click); lst_index.DataSource = Indexer.Items; lst_index

Powershell - can INotifyPropertyChanged be implemented natively?

巧了我就是萌 提交于 2019-12-11 09:26:54
问题 Does anyone know if the INotifyPropertyChanged interface can be implemented on an object in Powershell natively, without building a C# class and using Add-Type to generate a new .NET assembly? I've Googled everything I can think of and haven't been able to find a solution. Thanks. 回答1: No. Consider PowerShell a CLI consumer language and not so much a producer language. That is you can construct and use most .NET types. However PowerShell doesn't natively provide a facility to create new .NET

How to use a static utility method for property setters in a utility class

本秂侑毒 提交于 2019-12-11 07:49:02
问题 I'm trying to achieve two-way binding between a DataGridView and a BindingList that provides data for the DGV. Some columns do not yet reflect changes in the underlying list and I think it's because I have not provided property setter(s) to notify of property changes. Rather than code the setter for the Rows property the same way I did for the Process property, I'm trying to get more "elegant" and I realize I am stuck.... I stumbled upon a very interesting writeup for a more elegant approach

How to get updated automatically WPF TreeViewItems with values based on .Net class properties?

谁说我不能喝 提交于 2019-12-11 07:30:01
问题 Good morning. I have a class with data derived from InotifyPropertyChange. The data come from a background thread, which searches for files with certain extension in certain locations. Public property of the class reacts to an event OnPropertyChange by updating data in a separate thread. Besides, there are described in XAML TreeView, based on HierarhicalDataTemplates. Each TextBlock inside templates supplied ItemsSource = "{Binding FoundFilePaths, Mode = OneWay, NotifyOnTargetUpdated = True}"

PropertyChangedEventHandler is null even property is change

廉价感情. 提交于 2019-12-11 07:26:40
问题 I have a data grid and one main checkbox. When I check changed in the main checkbox, this will affect all checkbox that inside data grid; I just do it programmatically. My so-called ViewModel : foreach (TimeSheetModel value in TimeSheetList.Intersect(selectedlist)) { if (!chkmain.IsChecked.GetValueOrDefault()) { value.IsApproved = false; } else { value.IsApproved = true; } } This is my TimeSheetModel : public class TimeSheetModel:BaseModel, ICloneable { bool _IsApproved; public bool