Click here to Skip to main content
15,897,334 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hello All,

During runtime iam drawing multiple shapes(path,rectangle,ellipse) on the canvas on a WPF Window and storing the shapes information in a List
What iam trying to do is when i right click on any shape, i want to display a property window which show the deatils of that shapeon the propert window like
Height: 50
width: 80
Position X: 80 Y: 100
....
...etc
for this iam creating labels and Textboxes dynamically added to wrapPanel

C#
Label lblposition=new Label ();
lblposition.Height=25;lblposition.Width=225;lblposition.Content="Position";

// label			   		
Label lblPosX=new Label ();	
lblPosX.Height=25;lblPosX.Width=25;lblPosX.Content="X";
//Textbox
TextBox txtposX=new TextBox();txtposX.Height=25;txtposX.Width=75;txtposX.Text=list1[getindex].Position.X.ToString();
//Button to save
Button btnsaveData=new Button ();
btnsaveData.Height=25;btnsaveData.Width=200;btnsaveData.Content="Save";
btnsaveData.Click+=new RoutedEventHandler(btnsaveData_Click);

// some controls are also created in foreach loop (eg: for path each click point is stored in list and controls are cretaed to display each point location from list.

property window also contains one button to save the displayed information in a XML file.
iam able to create a window with controls and display the details in the textboxes reading from the list
Problem is
C#
private void btnsaveData_Click(object sender, RoutedEventArgs e)
 {
     // How should i read the textboxes values which are created in the above method.     
 }


iam unable to read the textboxes values of the property window in the button eventhandler

plZ can some one guide me in the right way to achieve this.

Thanks in advance.
Posted
Updated 26-Dec-11 0:41am
v4
Comments
Sergey Alexandrovich Kryukov 26-Dec-11 12:21pm    
I wonder what is that mysterious kind of use of a text box that you would call "non-dynamic"?
--SA

1 solution

Change the button to use an ICommand as its command instead of a Click. That way, when you create the command you can pass the relevant textbox to the command's CommandParameter which will be passed to the Execute method of the command automagically by the WPF framework.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900