升级到Visual Studio 2015会出现错误错误

时间:2015-12-29 18:06:18

标签: c# wpf visual-studio-2015

我已将VS 2012的项目升级到VS 2015,我遇到了奇怪的错误。在某些窗口上,它会抱怨颜色和画笔定义,即使我对任何颜色或画笔都没有做任何事情。项目将编译,但编辑器会出错。例如,在XAML代码上:

    <ComboBox x:Name="cbCountry" Grid.Column="1"   VerticalAlignment="Bottom"  Height="28" FontSize="12" SelectionChanged="cbCountry_SelectionChanged" 
              HorizontalContentAlignment="Stretch" IsEditable="True" StaysOpenOnEdit="True" IsManipulationEnabled="True" KeyUp="cbCountry_KeyUp" />

抱怨颜色。咦?什么颜色?这是一个非常香草的页面,没有任何花哨的东西,任何人都有任何想法如何消除这些错误?

enter image description here

更新 我将一些Windows资源定义为:

<Window.Resources>
    <DataTemplate x:Key="CityTemplate">
        <StackPanel Orientation="Horizontal">
            <Border BorderThickness="1" BorderBrush="Black">
                <TextBlock Text="{Binding City}" />
            </Border>
        </StackPanel>
    </DataTemplate>
</Window.Resources>

确实定义了BorderBrush,但没有定义组合。我尝试从BorderBrush开始一次拿出一块。直到我完全删除了<Windows.Resources>部分,错误就消失了。有没有人在Windows资源中看到任何错误导致此问题?

更新2
这个问题似乎与任何背后的代码无关。整个XAML如下:

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:ig="http://schemas.infragistics.com/xaml" 
        x:Class="PTHWPF.View.Lookup" 
        Title="Lookup Place of Birth" Height="400" Width="600" Loaded="Window_Loaded" 
        Icon="/PTHWPF;component/Resources/Images/LookupMap.png">
    <!--TextBlock.TextAlignment="Center" -->
<Window.Resources>
        <DataTemplate x:Key="CityTemplate">
            <StackPanel Orientation="Horizontal">
                <Border BorderThickness="1" BorderBrush="Black">
                    <TextBlock Text="{Binding City}" />
                </Border>
            </StackPanel>
        </DataTemplate>
    </Window.Resources>
    <Grid IsManipulationEnabled="True" >
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="110" />
            <ColumnDefinition Width="280*" />
            <ColumnDefinition Width="180*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="60" />
            <RowDefinition Height="50" />
            <RowDefinition Height="50" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Label Content="Country or State" Height="28" HorizontalAlignment="Right"  x:Name="lbCountry" VerticalAlignment="Bottom" />
        <ComboBox x:Name="cbCountry" Grid.Column="1"   VerticalAlignment="Bottom"  Height="28" FontSize="12" SelectionChanged="cbCountry_SelectionChanged" 
                  HorizontalContentAlignment="Stretch" IsEditable="True" StaysOpenOnEdit="True" IsManipulationEnabled="True" KeyUp="cbCountry_KeyUp"  >
        </ComboBox>
        <Label Content="City" Grid.Row="1" Height="28" HorizontalAlignment="Right"  x:Name="lbCity" VerticalAlignment="Bottom" />
        <ig:XamMultiColumnComboEditor SelectionChanged="cbCity_SelectionChanged"
            Grid.Column="1" Grid.Row="1" 
            HorizontalAlignment="Stretch" 
            x:Name="cbCity" Height="28" 
            VerticalAlignment="Bottom" 
            DataContext="{Binding}" 
            DisplayMemberPath="City" 
            HorizontalContentAlignment="Left" 
            IsTabStop="True" MinWidth="250" 
            FilterMode="FilterOnPrimaryColumnOnly"/>
        <DockPanel Grid.Column="1" Grid.Row="2" HorizontalAlignment="Center" >
            <Button Background="#9F7F90FC" Height="30" x:Name="btnOk" Width="80" Style="{DynamicResource RoundedButton}" HorizontalAlignment="Left" IsDefault="True" Click="btnOk_Click" VerticalAlignment="Bottom" Margin="0,0,20,0">
                <StackPanel Orientation="Horizontal">
                    <Image Height="20" Source="/PTHWPF;component/Resources/ok.png" Width="20" />
                    <AccessText Margin="5,3,0,0" x:Name="btnOkText" Text="_Ok"/>
                </StackPanel>
            </Button>
            <Button Background="#9F7F90FC" BorderBrush="#95FFFFFF" Height="30" x:Name="btnCancel" Style="{DynamicResource RoundedButton}" Width="80" IsCancel="True"  Click="btnCancel_Click" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="20,0,0,0">
                <StackPanel Background="{x:Null}" Orientation="Horizontal">
                    <Image Height="20" Source="/PTHWPF;component/Resources/Images/cancel.png" Width="20" />
                    <AccessText Margin="5,3,0,0" x:Name="btnCancelText" Text="_Cancel"/>
                </StackPanel>
            </Button>
        </DockPanel>
    </Grid>
</Window>

1 个答案:

答案 0 :(得分:1)

显然Visual Studio 2015企业版存在一些问题,其中还包括&#34; Handler = ...&#34;这里发现的错误: https://connect.microsoft.com/VisualStudio/feedback/details/1611888/xaml-editor-error-invalid-value-for-property-handler-and-ischecked-bug-remains-in-the-enterprise-version-of-vs-2015

我在其他XAML文件上也遇到过它,但它并没有导致设计器失败。

<强>解决方案:
升级到此处的Service Pack 1:
https://www.visualstudio.com/en-us/news/vs2015-update1-vs.aspx

这是一次网络更新,需要一个多小时才能完成。我还需要重新启动Windows才能完成,所以请记住这一点。希望任何发现这篇文章的人都不会像我一样花上几天来解决这个问题。