Visual State Manager上的VS2010 WPF设计器中的InvalidOperationException [英] InvalidOperationException in VS2010 WPF Designer on Visual State Manager

查看:91
本文介绍了Visual State Manager上的VS2010 WPF设计器中的InvalidOperationException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过控件模板和资源管理器添加WPF样式时VS2010在设置某些属性时控件的设计器中抛出InvalidOperationException错误,该链接返回到视觉状态。我认为这必须是
我创建Visual States的方式(我正在使用Blend 4.0)但我也得到了相同的错误,即使使用从msdn站点下载的ControlTemplateExamples也是如此。 

http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=wpfsamples&DownloadId=7741

When adding WPF styles through control templates and resourcedictionarys VS2010 throws an InvalidOperationException error in the designer on controls when certain properties are set, that link back to the Visual States. I thought this must be the way i was creating the Visual States (i am using Blend 4.0) but I am also getting the same error, even using the ControlTemplateExamples downloaded from the msdn site.  http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=wpfsamples&DownloadId=7741

我打开了VS2010中的解决方案,然后打开MainWindow.xaml(分屏 -  设计器和标记)

I opened up the solution in VS2010, then opened MainWindow.xaml (split screen - designer and markup)

System.InvalidOperationException

'System.Windows.Media.Animation.ColorAnimation'动画对象不能用于动画属性'Foreground',因为它是不兼容的类型'System.Windows。 Media.Brush'。

'System.Windows.Media.Animation.ColorAnimation' animation object cannot be used to animate property 'Foreground' because it is of incompatible type 'System.Windows.Media.Brush'.

...有11个错误,但解决方案成功构建并运行良好。

... there are 11 errors but the solution builds successfully and runs fine.

如果您查看MainWindow.xaml中的标记和第一组按钮,则第一个错误链接到"IsEnabled"和"IsEnabled"。属性

If you look at the markup in MainWindow.xaml and the first set of buttons, the first error is linked to the "IsEnabled" property

< 按钮
Margin =
" 8"
IsEnabled = " False"
内容= "禁用"

/>

<Button Margin="8" IsEnabled="False" Content="Disabled" />

查看Button.xaml中的相应模板和VisualState"已禁用"...如果删除可视状态,则会从MainWindow.xaml标记中删除错误。查看其余部分他们似乎将
链接到控件属性上的可视状态的错误,如果在标记上设置(如IsEnabled,ReadOnly等)会导致设计者抛出无效操作异常。

Look at the corresponding template in Button.xaml and the VisualState "Disabled" ... if you remove the visual state then the error is removed from the MainWindow.xaml Markup. Looking at the rest of the errors they seem to be linked to visual states on Control Properties that if set on the markup (like IsEnabled, ReadOnly, etc) cause the designer to throw the Invalid Operation Exception.

希望你能帮忙

干杯...... Rob。 

Cheers ... Rob. 

推荐答案

我遇到了从Blend 4到VS 2010的样式的类似问题.XAML在Blend 4和VS中的运行模式下完美运行,但设计师无法处理它。

I got a similar problem with a style transfered from Blend 4 to VS 2010. The XAML works perfectly in Blend 4 and in Run mode in VS, but the designer cannot handle it.

我有一个IsEnabled声明的触发器,女巫为Panel.Background分配一个新的GrdientBackground。据我所知,这些作业(对'Panel.Background')导致了这个问题。

I have a trigger for IsEnabled declared, witch assigns a new GrdientBackground to the Panel.Background. As far as I know, these assignments (to 'Panel.Background') are the ones causing this problem.

更具体地说,设计师给了我这个特定的错误:

More specificly, the designer gives me this specific error:

'系统.Windows.Media.Animation.ColorAnimationUsingKeyFrames的动画对象不能用于动画属性'BorderBrush',因为它是不兼容的类型'System.Windows.Media.Brush'。

'System.Windows.Media.Animation.ColorAnimationUsingKeyFrames' animation object cannot be used to animate property 'BorderBrush' because it is of incompatible type 'System.Windows.Media.Brush'.

我也得到错误列表中列出的错误(非常有帮助; - ):

I also get an error listed in the error list (very helpfull ;-):

'[Unknown]'属性不指向路径'(0)中的DependencyObject。(1)[1] 。(2)'

'[Unknown]' property does not point to a DependencyObject in path '(0).(1)[1].(2)'

您的问题与"Panel.Background"的分配有关吗?或者是渐变色的赋值?还是某种颜色?

Is your problem related to an assignment to 'Panel.Background'? Or to an assignment of a gradient color? Or color of some kind?

对不起,我没有给你一个答案,但是我教mabee将我的经验添加到这个帖子会碰到线程并让专家得到关于这个问题的更多信息(如果它是同一个问题...)

I am sorry I don't have an answer for you, but I taught mabee adding my experience to this thread would bump the thread and allow an expert to get more info on the issue (if it IS the same issue...)

感谢您的时间!


这篇关于Visual State Manager上的VS2010 WPF设计器中的InvalidOperationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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