本文介绍了任何类型的system.windows.controls作为函数[C#]中的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在尝试创建一个将PreviewMouseDown事件分配给任何类型的System.Windows.Controls的函数。但是我应该输入什么作为参数呢? 我尝试了什么: 对于尝试这样的事情感到愚蠢I'm trying to create a function that assigns a "PreviewMouseDown" event to any type of System.Windows.Controls. But what should I type as a parameter?What I have tried:feel silly for trying something like thispublic static void dragcontrol(object ctrl) { ctrl.GetType() test = ctrl as System.Windows.Controls; }推荐答案private void Attach(System.Windows.UIElement uiElement){ uiElement.PreviewMouseDown += UiElement_PreviewMouseDown;} 这篇关于任何类型的system.windows.controls作为函数[C#]中的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!