inotifypropertychanged

POCOs and multiple ViewModels pointing to the same POCO?

こ雲淡風輕ζ 提交于 2019-12-09 04:38:41
How would one go about handling a situation like this? Having more than one ViewModel having a reference to the same POCO object. ViewModel A updates the POCO... now ViewModel B needs to know about this somehow? Assuming that your POCO can't implement INotifyPropertyChanged , you could use a mediator pattern to alert other view models when a POCO is changed: public interface ICareWhenAModelChanges<T> { void ModelUpdated(T updatedModel); } public class ModelChangeMediator<T> { private List<ICareWhenAModelChanges<T>> _listeners = new List<ICareWhenAModelChanges<T>>(); public void Register

How to detect if an item in my ObservableCollection has changed

北战南征 提交于 2019-12-09 04:38:39
问题 I have a datagrid which is bound to ObservableCollection<Product> . When the grid is updated this automatically updates the Product object in my collection. What I want to do now is to have some sort of even that is triggered when any object in the collection is updated -or- some sort of binding to the collection that will return true/false depedant on if any Product has been updated. The overall objective is to have a save button on my main window that is disabled if no changes have been

Should our own code subscribe to PropertyChanged?

非 Y 不嫁゛ 提交于 2019-12-08 23:12:30
We have a number of data objects that realize INotifyPropertyChanged to allow for WPF Binding updates. There are also a number of places where our code subscribes to PropertyChanged because we're interested in some value updates. This results in pretty ugly code where we need to check which property actually changed (we do this using Expressions so it's always type/refactor safe). Is the preference to raise a specific event (PriceChanged etc...) for when we want to subscribe to it, or hook into PropertyChanged and check the property name? olldman If a number of properties you want to subscribe

Observable Collection Notify when property changed in MVVM

橙三吉。 提交于 2019-12-08 16:05:36
问题 I am trying to bind observable collection to DataGrid, i want to notify when any row is edited in datagrid. My code works fine for notifing when record is added or removed but its not notifing when record is edited. Please let me know if this is the right way of binding using observable collection in MVVM and whether i am missing someting. Thanks in advance. public class studentViewModel : INotifyPropertyChanged { #region constructor public studentViewModel() { _student = new studentModel();

Silverlight MVVM, stop SelectionChanged triggering in response to ItemsSource reset

孤街醉人 提交于 2019-12-08 12:45:36
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 - changing the selection in A causes B to be repopulated with new items. Now, the problem is that B's

PropertyChanged Event Not Bubbling Up C#

两盒软妹~` 提交于 2019-12-08 10:50:52
问题 I'm designing a simple model that can be edited on a screen. In this case, it's for Xamarin Forms UWP, but this model class is platform agnostic, and I doubt that it's a UWP/Xamarin specific problem. I need the code to work so that if I edited any property in the model, the event should bubble up to the top, and I should be able to handle the PropertyChanged event on UserPreferences to save the record. But, this event never gets fired no matter which properties are changed. I can see that the

INotifyPropertyChanged event not firing when Observable Collection changed in WPF in VB.NET

眉间皱痕 提交于 2019-12-08 09:25:51
问题 I'm trying to use databinding in WPF with an MVVM pattern. So far, it seems that everything is plumbed up properly and I'm using the right type of classes and objects. My observable collection loads to first time correctly, but won't refresh on the datagrid when it changes. Observable Collections should automatically implement INPC and I've also provided a handler for it in my base class, so I'm confused why it is still not working and updating my UI. Here's my code below: ViewModelBase Class

How to implement INotifyPropertyChanged for WPF ProgressBar

本秂侑毒 提交于 2019-12-08 06:22:31
问题 I am going through the tutorials on how to implement INotifyPropertyChanged for a progressbar and I think i am a bit confused. This is my XAML code snippet: <ProgressBar Name="progressBar" Height="24" IsIndeterminate="{Binding IsIndeterminate}" Minimum="{Binding Minimum}" Maximum="{Binding Maximum}" Value="{Binding ProgressValue}"/> and this is my code-behind snippet: public partial class MainWindow : System.Windows.Window { public bool IsInderteminate { get; set; } public double Minimum {

WPF binding to property of all items in a collection

梦想与她 提交于 2019-12-08 04:54:50
问题 I need to bind to a bool property, that is only true, when one of the properties in the collection is true. This is the binding: <tk:BusyIndicator IsBusy="{Binding Tabs, Converter={StaticResource BusyTabsToStateConverter}}"> And the viewmodel: public class MainWindowViewModel : INotifyPropertyChanged { private ObservableCollection<Tab> _tabs; public ObservableCollection<Tab> Tabs { get { return _tabs; } set { if (value != _tabs) { _tabs = value; NotifyPropertyChanged(); } } } The Tab class

POCOs and multiple ViewModels pointing to the same POCO?

蹲街弑〆低调 提交于 2019-12-08 04:16:33
问题 How would one go about handling a situation like this? Having more than one ViewModel having a reference to the same POCO object. ViewModel A updates the POCO... now ViewModel B needs to know about this somehow? 回答1: Assuming that your POCO can't implement INotifyPropertyChanged , you could use a mediator pattern to alert other view models when a POCO is changed: public interface ICareWhenAModelChanges<T> { void ModelUpdated(T updatedModel); } public class ModelChangeMediator<T> { private