如何在wpf中的代码中使用VisualStateManager。 [英] How to use VisualStateManager in code behind in wpf.

查看:320
本文介绍了如何在wpf中的代码中使用VisualStateManager。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello专家,



在现有的应用程序中,使用目标框架3.5和IDE VS2008,我们正在使用WPF工具包日期选择器。这些日期选择器有一个问题,因为当它们以编程方式启用时,它们的外观仍然像一个禁用的控件,但它们是可点击的。

请参阅此链接以获取更多信息:

< a href =https://wpf.codeplex.com/workitem/14273> https://wpf.codeplex.com/workitem/14273 [ ^ ]



为了解决这个问题,我们编写了以下事件:

Hello experts,

In an existing application, with target framework 3.5 and IDE VS2008, we are using WPF toolkit datepickers. These datepickers, have an issue as, when they are enabled programatically, their appearance remains like a disabled control but they are clickable.
Refer this link for further info:
https://wpf.codeplex.com/workitem/14273[^]

To handle this, we wrote the following event :

private void dt_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
{
   System.Windows.Controls.DatePicker datePicker = sender as System.Windows.Controls.DatePicker;
   if (datePicker.IsEnabled)
     System.Windows.VisualStateManager.GoToState(datePicker, "Normal", true);
   else
     System.Windows.VisualStateManager.GoToState(datePicker, "Disabled", true);
}





现在,这在VS2008上运行良好。但是现在当我们升级我们的解决方案时,在VS2012中,VisualStateManager抛出了编译时错误:



'C:'中存在类型'System.Windows.VisualStateManager': \Program Files(x86)\ Reference Assemblies\Microsoft \ Framework \.NETFramework \v4.5 \ PresentationFramework.dll'和'WPFToolkit.dll'



我google了很多,但没有得到任何好的解决方案。



请有人在这里帮助我,我该如何消除这种歧义。



问候,

Praneet



Now, this worked fine with VS2008. But now when we upgraded our solution, in VS2012, the VisualStateManager is throwing compiletime error.:

The type 'System.Windows.VisualStateManager' exists in both 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationFramework.dll' and 'WPFToolkit.dll'

I googled a lot, but did not get any good solution.

Please can anyone help me here, how should I remove this ambiguity.

Regards,
Praneet

推荐答案

我不确定,但你可以尝试一下吗?删除WPFToolKit.dll的引用。
I am not sure, but can you try with removing reference of "WPFToolKit.dll".


这篇关于如何在wpf中的代码中使用VisualStateManager。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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