How to get the RegisterName in WPF

  • Thread starter Thread starter rainnie1314
  • Start date Start date
R

rainnie1314

Guest
I dynamic create the button using code like this:

private void mainArea_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
targetPoint = e.GetPosition((IInputElement)sender);
Uid id = new Uid();
string uid = id.getUid();
_target = new Button()
{

content = "station",

Name = "station" + uid

};
Canvas.SetTop(_target, targetPoint.Y - 60);
Canvas.SetLeft(_target, targetPoint.X - 20);
mainArea.Children.Add(_target);
mainArea.RegisterName(_target.Name, _target);
}

And the "uid" is a random number, after this code i can create button on Canvas, but when i try to delete it or do something else , i found i cant get the name of the button.

so anyone can tell me how to get the name or registername of this button or the button that i click?

Continue reading...
 

Similar threads

D
Replies
0
Views
150
dabina2018
D
E
Replies
0
Views
88
elfenliedtopfan55
E
E
Replies
0
Views
91
elfenliedtopfan55
E
B
Replies
0
Views
584
Bryan Prendergast
B
M
Replies
0
Views
117
Matt Armshaw
M
Back
Top