简体   繁体   English

Visual Studio 2012和2013与2010在颜色属性方面的行为不同

[英]Different behavior in Visual Studio 2012 and 2013 verses 2010 on Color Property

I have a custom WPF Control that has a System.Drawing.Color property. 我有一个具有System.Drawing.Color属性的自定义WPF控件。 The control works in Visual Studio 2010. for example if you select White the XAML generated is Property="White" but in 2012 or 2013 the XAML is Property="Color [White]" which is incorrect. 该控件可在Visual Studio 2010中使用。例如,如果选择“白色”,则生成的XAML为Property =“ White”,但在2012或2013年,XAML为“属性=” Color [White]“,这是不正确的。 Also want to point out that in the property Combo Box the same thing is happening 2010 displays a list of color in the format of the color Name eg. 还需要指出的是,在“组合框”属性中,2010年正在发生相同的事情,以颜色名称的格式显示颜色列表。 White were in 2012 or 2013 the property combo box displays a list of colors like Color[White]. 白色分别在2012或2013年,属性组合框显示诸如Color [White]之类的颜色列表。

Is there a setting that is different in 2012 or 2013 that can cause this or any idea why this would be happening? 2012年或2013年的设置是否不同,可能会导致这种情况或任何想法,为什么会发生这种情况?

Edit: Here is and Example. 编辑:这是和示例。

The problem is simple to duplicate using a user control with one property MyColor. 使用具有一个属性MyColor的用户控件可以很容易地复制该问题。 Creating the same control in Visual Studio 2010 and in Visual Studio 2012 produces different results. 在Visual Studio 2010和Visual Studio 2012中创建相同的控件会产生不同的结果。 Both applications are targeting 4.0 framework and reference the same version of System.Drawing V4.0.30319. 这两个应用程序都以4.0框架为目标,并引用相同版本的System.Drawing V4.0.30319。 I know this example could use brushes but the actual control cannot. 我知道此示例可以使用画笔,但实际控件不能。 I am limited to using System.Drawing.Color. 我仅限于使用System.Drawing.Color。 Any insight would great. 任何见识都会很棒。

Public Class UserControl1
    Private m_MyColor As System.Drawing.Color
    Public Property MyColor As System.Drawing.Color
        Get
            Return m_MyColor
        End Get
        Set(value As System.Drawing.Color)
            m_MyColor = value
        End Set
    End Property
End Class

The results when setting this property in 2010: 在2010年设置此属性时的结果:

<my:UserControl1 HorizontalAlignment="Left" Margin="10,10,0,0" x:Name="UserControl11" VerticalAlignment="Top" Height="98" Width="103" MyColor="White" />

The results wen setting this property in 2012: 在2012年设置此属性的结果是:

<local:UserControl1 HorizontalAlignment="Left" Height="79" Margin="10,10,0,0" VerticalAlignment="Top" Width="96" MyColor="Color [White]"/>

Any help would be greatly appreciated. 任何帮助将不胜感激。

在Visual Studio 2015更新2中已解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM