Design: Passing parameters [modified]
-
Hello all, I am learning WPF now. I have a window which will launch a popup on click of a button. The popup contains a user control. I need to pass some parameters like first name,last name to the user control. I am from an asp.net background so my thought is like to pass these parameters as query string and assign it to the text box in popup. Any way, it is not possible in windows and I am sure there are better methods. I am thinking about declaring a public get-set property in the popup for each parameters(I don't think I need dependency property). Then I will assign the values from the window. Is it a good way of doing it? Thanks in advance, afsal
modified on Wednesday, December 22, 2010 10:15 AM
-
Hello all, I am learning WPF now. I have a window which will launch a popup on click of a button. The popup contains a user control. I need to pass some parameters like first name,last name to the user control. I am from an asp.net background so my thought is like to pass these parameters as query string and assign it to the text box in popup. Any way, it is not possible in windows and I am sure there are better methods. I am thinking about declaring a public get-set property in the popup for each parameters(I don't think I need dependency property). Then I will assign the values from the window. Is it a good way of doing it? Thanks in advance, afsal
modified on Wednesday, December 22, 2010 10:15 AM
If your pop-up's job is to display first name and last name then I would guess that you probably have (for example) a Customer object, with properties of FirstName and LastName (for example) your usercontrol could bind to such an object your popup then would need an instance of that object to set as the datasource - so either have a public property
public Customer CurrentCustomer
{
set
{
//Do your databinding here
}
}or have a constructor which takes a Customer as a parameter, and performs the binding. Using the property at least gives you the potential option of changing the Customer without closing and re-opening the pop up.
___________________________________________ .\\axxx (That's an 'M')