簡體   English   中英

升級到Visual Studio 2015會出現錯誤

[英]Upgrade to Visual Studio 2015 gives false errors

我已經將一個項目從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" />

抱怨顏色。 咦? 什么顏色? 這是一個非常香草的頁面,沒有任何花哨的東西,任何人有任何想法如何消除這些錯誤?

在此輸入圖像描述

更新我有一些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>

顯然Visual Studio 2015企業版有一些問題,這也包括“Handler = ...”錯誤,如下所示: https//connect.microsoft.com/VisualStudio/feedback/details/1611888/xaml-editor-error-無效值換財產處理和-器isChecked-bug的遺體,在最企業版本的-VS-2015

我在其他XAML文件上遇到過它,但它並沒有導致設計器失敗。

解:
升級到Service Pack 1,可在此處找到:
https://www.visualstudio.com/en-us/news/vs2015-update1-vs.aspx

這是一次網絡更新,花了一個多小時才完成。 我還需要重新啟動Windows才能完成,所以請記住這一點。 希望任何發現這篇文章的人不會像我一樣花幾天時間來解決這個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM