How can I create some random time, like 10 seconds. So when I click the button I have to wait 10 seconds to see the new button? My question is how to create that random time? And it has to be in Xaml
My code:
public void randomButton()
{
newBtn.Content = "A New Button";
Random myRandom = new Random();
int rand1 = myRandom.Next(0, 400);
int rand2 = myRandom.Next(0, 400);
panelButton.Children.Add(newBtn);
Canvas.SetLeft(newBtn, rand1);
Canvas.SetTop(newBtn, rand2);
iRandom = row.Next(-350, 350);
newBtn.Click += newBtn_Click;
newBtn.Margin = new Thickness(iRandom, iRandom, 0, 0);
}
private void newBtn_Click(object sender, RoutedEventArgs e)
{
*// here i want the random time to happen!*
iRandom = row.Next(-350, 350);
newBtn.Margin = new Thickness(iRandom, iRandom, 0, 0);
}
Please help me, I really want to know it! Sorry for my bad Englisch!
Aucun commentaire:
Enregistrer un commentaire