inotifypropertychanged

and events (INotifyPropertyChanged, specifically)

早过忘川 提交于 2019-12-10 19:23:56
问题 I've run into a really strange problem I can't seem to reproduce with a small example. Sorry if this question is a little vague. I have a Person which contains an Address. Both inherit from BaseEntity which implements INotifyPropertyChanged. I want the Person class to NotifyPropertyChanged("Address") not only when an Address is set, but also when that Address itself changes, so my get/set in Person looks like this: class Person : BaseEntity { private Address address; public Address Address {

INotifyPropertyChanged does not work when the property set to a same value for the second time

大城市里の小女人 提交于 2019-12-10 15:58:39
问题 This is the code to reproduce this issue: xaml: <Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <TextBox Text="{Binding Num, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"></TextBox> </Grid> C#: using System.ComponentModel; using System.Windows; namespace WpfApplication1 { public partial class MainWindow : Window { public

Binding to a dictionary in Silverlight with INotifyPropertyChanged

China☆狼群 提交于 2019-12-10 15:57:04
问题 In silverlight, I can not get INotifyPropertyChanged to work like I want it to when binding to a dictionary. In the example below, the page binds to the dictionary okay but when I change the content of one of the textboxes the CustomProperties property setter is not called. The CustomProperties property setter is only called when CustomProperties is set and not when the values within it are set. I am trying to do some validation on the dictionary values and so am looking to run some code when

Change notification in EF EntityCollection

蓝咒 提交于 2019-12-10 15:35:40
问题 In a Silverlight 4 proj i'm using WCF RIA services, MVVM principles and EF 4. I 'm running into this situation: created an entity called Category and another one called CategoryLocale (automated using VS, no POCO). The relation between them is 1 to N respectively (one Category can have many CategoryLocales), so trough this relationship one can implement master-detail scenarios. Everytime i change a property in the master record (Category) i get a notifypropertychanged notification raised. But

WPF Simple Binding to INotifyPropertyChanged Object

孤街醉人 提交于 2019-12-10 13:29:42
问题 I've created the simplest binding. A textbox bound to an object in the code behind. Event though - the textbox remains empty. The window's DataContext is set, and the binding path is present. Can you say what's wrong? XAML <Window x:Class="Anecdotes.SimpleBinding" x:Name="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="SimpleBinding" Height="300" Width="300" DataContext="MainWindow"> <Grid> <TextBox

Updating value of TextBlock in wpf dynamically [Sovled]

坚强是说给别人听的谎言 提交于 2019-12-10 12:25:01
问题 I have text block on my UI. I would like to display some text on the text block dynamically. I have implemented it as given in the below code. however i do not see the values updating dynamically. I do see only the last updated value on UI text block. I have included a delay to notice the change. Please provide any solution or comment for more info.Thank you in advance. Code: namespace TxtBlock { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class

WPF DataGrid not updating on PropertyChanged

て烟熏妆下的殇ゞ 提交于 2019-12-10 01:52:41
问题 i've a problem updating my datagrid when clicking the button by using NotifyPropertyChanged. It works if i set the DataGrid.ItemsSource in code behind, but it doesn't if i set it in xaml. here's some code of code behind & xaml: namespace MyWpfDataBindingLab { public partial class NpcWindow : Window { DataCollection dc = new DataCollection(); public NpcWindow() { InitializeComponent(); //command binding code //... } private void Window_Loaded(object sender, RoutedEventArgs e) { //if i set the

DependencyProperty doesn't fire ValueChanged when new value is the same

ε祈祈猫儿з 提交于 2019-12-10 01:30:02
问题 Ok so here's the problem: I wrote a UserControl which receives a new value say like every 100ms and does something with it. It has to handle each new value setter, even if the value didn't change. The UserControl has a few DependencyProperties: public double CurrentValue { get { return (double)GetValue(CurrentValueProperty); } set { SetValue(CurrentValueProperty, value); } } public static readonly DependencyProperty CurrentValueProperty = DependencyProperty.Register("CurrentValue", typeof

A better way to write MVVM boilerplate code?

送分小仙女□ 提交于 2019-12-09 17:04:52
问题 I have found myself recently writing a lot of boilerplate MVVM code and wonder if there is a fancy way to get around writing it all? I already use a ViewModelBase class that implements INotifyPropertyChanged but that doesnt solve the problem of having to write all the accessor code etc. Perhaps by writing a custom attribute that does this, or via a templating system? public MyClass : ViewModelBase { private int someVariable; public int SomeVariable { get { return this.someVariable; } set {

Notify Changes on external parameter change

做~自己de王妃 提交于 2019-12-09 12:41:32
问题 I need to attach a notify change event to an encapsulated parameter in an external class. I usually would implement INotifyPropertyChanged , but I can't edit the external class. What is the right approach for this problem? 回答1: That will be very hard to do. The best option seems to be deriving that class, but you need all properties to be marked virtual . When you have no control over the class that seems to be unlikely. If you are the only one calling that class, you could also create a