如何使用VisualStateManager [英] How to use VisualStateManager
问题描述
大家好,
我正在使用WPF Toolkit的DatePicker,它有条件地启用。
工具包版本适用于.Net Framework 3.5
现在,当DatePicker IsEnabled设置为true时,它不会更改控件的禁用外观。
https://wpf.codeplex.com/workitem/14273 [ ^ ]
因此,为了解决这个问题,我使用了以下代码: br />
Hi All,
I am using a WPF Toolkit's DatePicker which gets enabled conditionally.
The toolkit version is for .Net Framework 3.5
Now, when DatePicker IsEnabled is set to true, it does not change the disable appearance of the control.
https://wpf.codeplex.com/workitem/14273[^]
Hence, to resolve this, I used the following code :
private void DatePicker_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
{
var dp = sender as Microsoft.Windows.Controls.DatePicker;
if ( dp.IsEnabled )
VisualStateManager.GoToState(dp, "Normal", true);
else
VisualStateManager.GoToState(dp, "Disabled", true);
}
当我将.Net Framework升级到4.0版时,我们收到以下错误:
When I upgraded the .Net Framework to version 4.0, we get the following error :
Error 1059 The type 'System.Windows.VisualStateManager' exists in both 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\PresentationFramework.dll' and 'D:\Lib\WPFLib\WPFToolkit.dll'
I我不知道如何解决这个问题。
此外,有什么办法可以通过在xaml中使用VisualStateManager实现这个目的
请建议一个可能的解决方案。
问候,
Praneet
I am not getting how should I resolve this.
Also, is there any way I can achieve this by using the VisualStateManager in xaml
Please suggest a possible solution.
Regards,
Praneet
推荐答案
VisualStateManager类是冲突的,因为它存在于指定的dll中 http://msdn.microsoft.com/en-us/library/system.wind ows.visualstatemanager(v = vs.110).aspx [ ^ ]
VisualStateManager class is conflicting, because it is present in specified both the dll's http://msdn.microsoft.com/en-us/library/system.windows.visualstatemanager(v=vs.110).aspx[^]
这篇关于如何使用VisualStateManager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!