Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do you bind to a property on a reference object?
Message
De
21/07/2008 21:52:42
 
 
À
21/07/2008 16:45:16
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Divers
Thread ID:
01331472
Message ID:
01333011
Vues:
8
Job.Customer.custno and Job.cust_num are the same value so I think i would just use the Job.Customer.custno and not worry about it since it is updating things correctly. That seems to be by design.

I think this is your answer as to why it doesn't update:
this._cust_num = value.custno;
Based on the underline that would be the private field being set not the public property. So the change event for cust_num is never called.

John

>I know it is binding up because the dialog box is popping up the right value immediately after picking a new Customer from the ComboBox. Ayway, I do have Mode=TwoWay on the ComboBox.
>
>I dug into the Linq-to-Sql generated code, which I have become pretty familiart with already, and here is there is some code on the the Job.cust_num field
>
>
> this.SendPropertyChanged("cust_num");
>
>
>
>However, I put a breakpoint on this code, and it does NOT get hit when changing customers.
>
>I saw some odd behavior though... When you change Customers, it actually goes though a complex manuever (sp?) of Dettaching the Job from the current Customer reference, and then Attaching the Job object to the chosen Customer object. Apparently, this is able to update the Customer without ever hitting the cust_num property setter.
>
>
>I suppose in light of this, I could just make a habit of making sure my UI controls are pointing to the referenced object properties, rather than the foreign keys of the main object. Perhaps this is by design for some reason.
>
>
>
>
>
>		[Association(Name="Customer_Job", Storage="_customer_source", ThisKey="cust_num", IsForeignKey=true)]
>		public Customer Customer
>		{
>			get
>			{
>				return this._customer_source.Entity;
>			}
>			set
>			{
>				Customer previousValue = this._customer_source.Entity;
>				if (((previousValue != value)
>							|| (this._customer_source.HasLoadedOrAssignedValue == false)))
>				{
>					this.SendPropertyChanging();
>					if ((previousValue != null))
>					{
>						this._customer_source.Entity = null;
>						previousValue.job_info.Remove(this);
>					}
>					this._customer_source.Entity = value;
>					if ((value != null))
>					{
>						value.job_info.Add(this);
>						this._cust_num = value.custno;
>					}
>					else
>					{
>						this._cust_num = default(string);
>					}
>					this.SendPropertyChanged("Customer");
>				}
>			}
>		}
>
>>
>>SubmitChanges() isn't needed here so you are right it looks like a change notification issue. Are you binding TwoWay? If not try that first.
>>
>>Linq2SQL implements INotifyPropertyChanged so if it is TwoWay... it should be working.
>>
>>It does not implement INotifyCollectionChanged which can be a pain sometimes.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform