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...
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...