Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do you bind to a property on a reference object?
Message
From
21/07/2008 16:45:16
 
 
To
21/07/2008 16:03:19
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Miscellaneous
Thread ID:
01331472
Message ID:
01332956
Views:
6
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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform