samedi 6 novembre 2021

How can I use sandbox in a class in c#

I have homework about wpf samples and apply desing patterns on them. And I have a problem, using sandbox in a class. For example,

public void Colorize()
        {
            var uic = Sandbox.Children;
            foreach (Shape uie in uic)
            {
                uie.Fill = new SolidColorBrush(Colors.Red);
            }
        }

And I can not fix that mistake,

var uic = Sandbox.Children; // there is a problem here about "Sandbox"

Normally it works in this button,

private void MakeEverythingRed(object sender, RoutedEventArgs e)
    {
        var uic = Sandbox.Children;
        foreach (Shape uie in uic)
        {
            uie.Fill = new SolidColorBrush(Colors.Red);
        }
    }

And I have to apply these codes into class for strategy pattern. So, How can I solve this problem ? In summerly , How can Sandbox does not give me an error when it's compile. Thank you so much..

By the way I take them into a class,

class makeRed : makeSomething
    {
       public void Colorize()
        {
            var uic = Sandbox.Children;
            foreach (Shape uie in uic)
            {
                uie.Fill = new SolidColorBrush(Colors.Red);
            }
        }
    }

Aucun commentaire:

Enregistrer un commentaire