inotifypropertychanged

Static property not updating in UI

て烟熏妆下的殇ゞ 提交于 2019-12-24 08:18:13
问题 I spent the last hour(s) trying to find an answer in google and stackoverflow. I followed different advices & suggestions, but nothing worked so far. My current code looks like this: public class GlobalManager : ViewModelBase { static object _LockObject_GFS = new object(); static double _GlobalFontSize; public static double GlobalFontSize { get { lock (_LockObject_GFS) { _GlobalFontSize = GetGlobalResource<double>(LambdaHelper.MemberToString(() => GlobalFontSize)); return _GlobalFontSize; } }

INotifyPropertyChanged issue, property is not being updated from Dispatcher

混江龙づ霸主 提交于 2019-12-24 05:56:40
问题 I have an issue with some of my properties not being updated when I use a Dispatcher from a separate thread. When I check for values in the array, they're all 0's. Properties: private string[] _years; public string[] Years { get { return _years; } private set { if (_years == value) { return; } _years = value; OnPropertyChanged("Years"); } } private int[] _yearCounts; public int[] YearCounts { get { return _yearCounts; } private set { if (_yearCounts == value) { return; } _yearCounts = value;

WPF: What is the right base class for collections used in data binding?

Deadly 提交于 2019-12-24 05:55:04
问题 I am building an object model with strongly typed collection classes (e.g. CustomerCollection ). I want to support full two-way binding on both the collection itself and all of the data models in the collection. For the models it seems like implementing INotifyPropertyChanged is the right way to wire up the models. But what inferface/base class should I use so that WPF knows when my collection's contents change? 回答1: ObservableCollection<T> - designed specifically for WPF binding. 回答2: I

DataContext Refresh and PropertyChanging & PropertyChanged Events

主宰稳场 提交于 2019-12-24 05:47:12
问题 I'm in a situation where I am being informed from an outside source that a particular entity has been altered outside my current datacontext. I'm able to find the entity and call refresh like so MyDataContext.Refresh(RefreshMode.OverwriteCurrentValues, myEntity); and the properties which have been altered on the entity are updated correctly. However neither of the INotifyPropertyChanging INotifyPropertyChanged appear to be raised when the refresh occurs and this leaves my UI displaying

MVVM INotifyPropertyChanged conflict with base class PropertyChange

余生颓废 提交于 2019-12-24 04:36:06
问题 I'm relatively new to MVVM and I'm trying to understand how INotifyPropertyChanged interface works and how to implement it in my models. The approach that I decided to take was to implement it in each of my Business Object classes. The problem with that approach is that when I bind my View to a property in a Base class the PropertyChanged event in that base class never gets initialized (is null) and therefore the View does not refresh the data for that element when my Model changes. I was

WPF ICommand CanExecute(): RaiseCanExecuteChanged() or automatic handling via DispatchTimer?

核能气质少年 提交于 2019-12-24 03:10:38
问题 I'm trying to determine the best way to cause ICommands' CanExecute() to be reflected in the UI. I understand that the Dispatcher is the WPF (engine?) that handles UI drawing, and that by default, the Dispatcher evaluates ICommands' CanExecute() method upon instantiation as well as active user interface (clicking the UI, or keyboard input.) Obviously, this is a problem when CanExecute() on any given ICommand changes, but neither mouse nor keyboard input is provided--and so the UI does not

Fire event on value change of double

安稳与你 提交于 2019-12-24 00:12:23
问题 I've used INotifyPropertyChanged within a custom class to fire an event when a variable has changed, but I was wondering if there was a simple way to fire an event on a single variable's change, such as a double. For instance, in a WPF app, if I have private double a; in MainWindow.xaml.cs , is there a simple way to fire the event any time a is assigned to? 回答1: If I understand you correctly, you need to create a Setter for a, which then fires the properychange event/custom event instead of

MVVM INotifyPropertyChanged with Automatic Property Name implementation

痴心易碎 提交于 2019-12-23 23:34:41
问题 From my understanding, we can use the INofityProperty in a MVVM style application with code similar to the following object _SelectedPerson; public object SelectedPerson { get { return _SelectedPerson; } set { if (_SelectedPerson != value) { _SelectedPerson = value; RaisePropertyChanged("SelectedPerson"); } } } Now, I've seen Josh Smith's excellent example where he implements extra code to capture what happens if the developer types in a Property name which isn't recognized, such as a typo!

Using INotifyPropertyChanged in WPF

穿精又带淫゛_ 提交于 2019-12-22 10:25:24
问题 Hi i am trying to use the NotifyPropertyChanged to update all the places where i am binding a property. For what i have searched the INotifyPropertyChanged is indicated to this cases. So i need help because i don't understand what i have wrong in here. And i really don't know what to do with the PropertyChange event. My question about that is, when he changes? What i have to more with him? Datagrid: <ListView Name="listView" ItemsSource="{Binding Categories}"/> An example when i change my

Avoid calling RaisePropertyChanged in every setter

两盒软妹~` 提交于 2019-12-22 08:35:05
问题 I want to get rid of the space consuming and repetitive RaisePropertyChanged-Properties on my model classes. I want my model class... public class ProductWorkItem : NotificationObject { private string name; public string Name { get { return name; } set { if (value == name) return; name = value; RaisePropertyChanged(() => Name); } } private string description; public string Description { get { return description; } set { if (value == description) return; description = value;