将颜色参数从一个evant函数传递到另一个函数 [英] pass color parameter from one evant function to another

查看:107
本文介绍了将颜色参数从一个evant函数传递到另一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将颜色对象从一个Event函数传递给第二个Event函数

我该怎么做?





  //  形成thet evant函数 


private void recgreen_MouseLeftButtonDown(对象发​​件人,MouseButtonEventArgs e)
{


}



// 到该evant函数

private void myCanvas_MouseLeftButtonDown( object sender,MouseButtonEventArgs e)
{


_startPoint = e.GetPosition(myCanvas);
_line = new Polyline();
// 这里我想根据启动的evant函数更改颜色

_line.Stroke = new SolidColorBrush(Colors.Black); // 根据启动的evant函数,黑色shoude为任何颜色
_line.StrokeThickness = < span class =code-digit> 1 ;

myCanvas.Children.Add(_ line);

}

解决方案

使用类成员存储此类变量,以便以后检索。

I want to pass the color object from one Event function to the second Event function
How can I do this?


// form thet evant function 


 private void recgreen_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            

        }



// to that evant function

  private void myCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {

            
            _startPoint = e.GetPosition(myCanvas);
            _line = new Polyline();
// Here I want to change the color according to evant function activated

            _line.Stroke = new SolidColorBrush(Colors.Black); //the black shoude be any color according to evant function activated
            _line.StrokeThickness = 1;

            myCanvas.Children.Add(_line);

        }

解决方案

Use a class member to store such a variable, for later retrieval.


这篇关于将颜色参数从一个evant函数传递到另一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆