Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在c语言中设置“dynamic”类型对象的动画#_C#_.net_Dll - Fatal编程技术网

C# 在c语言中设置“dynamic”类型对象的动画#

C# 在c语言中设置“dynamic”类型对象的动画#,c#,.net,dll,C#,.net,Dll,因此,我将一个窗口传递给一个dll,在那里我将其作为dynamic dynamic theWindow = ...; 我需要设置该窗口属性的动画,我尝试了以下操作: theWindow.BeginAnimation(theWindow.LeftProperty, _leftAnimation); 但它不起作用。因此,我采取的一个步骤是检查是否可以访问window.LeftProperty,但我得到以下异常: Microsoft.CSharp.RuntimeBinder.RuntimeBind

因此,我将一个窗口传递给一个dll,在那里我将其作为
dynamic

dynamic theWindow = ...;
我需要设置该窗口属性的动画,我尝试了以下操作:

theWindow.BeginAnimation(theWindow.LeftProperty, _leftAnimation);
但它不起作用。因此,我采取的一个步骤是检查是否可以访问window.LeftProperty,但我得到以下异常:

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Member 'System.Windows.Window.LeftProperty' cannot be accessed with an instance reference; qualify it with a type name instead
   at CallSite.Target(Closure , CallSite , Object )
   at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
   at blablabla ...
它说“改为用类型名限定它”,但我不知道它是什么意思

但是,属性是可访问的,并按预期工作:

theWindow.MaxWidth = theWindow.Width + 108;
谢谢您的帮助。

是一种静态方法,无法动态访问。你可以试试

theWindow.BeginAnimation(Window.LeftProperty, _leftAnimation);

它是一个静态成员,请改用
Window.LeftProperty
。此外,如果您知道另一个程序集返回的对象的类型(似乎是
UIElement
),则应尽早将其强制转换为该类型,并从那时起静态调用其方法。如果你不需要动态的东西,就把它扔掉。