jeudi 24 mars 2016

How can I give a textBox in Xaml 4 random colors?

txtbKleuren.Foreground = new SolidColorBrush(Color.FromArgb(100, 255, 125, 35)); I have 4 buttons with the names red, green, blue and yellow and a textblock. So when the color yellow comes on the textblock I have to press button yellow to get a point. How can i make the textblock randomly giving one of the 4 colors?

This is my code:

 public MainPage()
        {
            this.InitializeComponent();
            Random rand = new Random();

             txtbKleuren.Foreground = new SolidColorBrush(Color.FromArgb(100, 255, 125, 35)); 

        }

        private void btnKleur4_Click(object sender, RoutedEventArgs e)
        {

        }

I don't know how to give a random color to the textbox so i just tried something! Please help me out. I really want to know it! And sorry for my bad Englisch.




Aucun commentaire:

Enregistrer un commentaire