在Blend for Visual Studio中使用异常

Jor*_*dan 11 expression-blend

每隔一段时间我就会在Blend for Visual Studio中获得编译器异常.一切都在编译和工作奇妙,然后突然BAM!我收到编译器错误,告诉我对象在特定的命名空间中不存在.我必须玩清洁和重建,关闭和重新开放Blend一个小时才能离开.我的图书馆都是最新的,一切都很好.没有其他人会发生这种情况吗?拜托,我希望它能阻止它是一个巨大的时间杀手.

我也在Visual Studio中得到编译器错误.

谢谢.

更新

例如,

错误5 XML名称空间" http://schemas.microsoft.com/expression/blend/2008 " 中不存在属性"DesignWidth ".第15行位置5. C:\ MyPath\MyControl.xaml 15 5 EasyBuilder

据我所知,DesignWidth该命名空间中确实存在很多.

XAML(不是它会帮助你)

<UserControl x:Name="UserControl" x:Class="EasyBuilder.MainControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:ignore="http://www.ignore.com"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" 
             xmlns:surface="http://schemas.microsoft.com/surface/2008" 
             xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
             xmlns:gif="http://wpfanimatedgif.codeplex.com"
             xmlns:local="clr-namespace:EasyBuilder"
             xmlns:res="clr-namespace:EasyBuilder.Infrastructure.Resources"
             xmlns:system="clr-namespace:System;assembly=mscorlib"
             d:DesignWidth="640" d:DesignHeight="480">
    <UserControl.Resources>
        <res:MainViewStrings x:Key="LocalStrings" />
    </UserControl.Resources>

    <UserControl.DataContext>
        <Binding Path="Main" Source="{StaticResource Locator}"/>
    </UserControl.DataContext>

    <Grid x:Name="LayoutRoot" Background="{DynamicResource PageBackgroundBrush}">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="OpenSelectionStateGroup">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0:0:0.15">
                        <VisualTransition.GeneratedEasingFunction>
                            <CircleEase EasingMode="EaseOut"/>
                        </VisualTransition.GeneratedEasingFunction>
                    </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="SelectionClosedState"/>
                <VisualState x:Name="SelectionOpenedState">
                    <Storyboard>
                        <BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsHitTestVisible)" Storyboard.TargetName="OpenFileSelection">
                            <DiscreteBooleanKeyFrame KeyTime="0" Value="False"/>
                        </BooleanAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="CloseFileSelection">
                            <EasingDoubleKeyFrame KeyTime="0" Value="1"/>
                        </DoubleAnimationUsingKeyFrames>
                        <BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsHitTestVisible)" Storyboard.TargetName="CloseFileSelection">
                            <DiscreteBooleanKeyFrame KeyTime="0" Value="True"/>
                        </BooleanAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="OpenFileSelection">
                            <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="FileSelectionShadow">
                            <EasingDoubleKeyFrame KeyTime="0" Value="12.5"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="FileSelection">
                            <EasingDoubleKeyFrame KeyTime="0" Value="450"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="FileSelectionControl">
                            <EasingDoubleKeyFrame KeyTime="0" Value="1"/>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <Frame x:Name="ContentFrame" Margin="0,0,100,0" Grid.ColumnSpan="2" NavigationUIVisibility="Hidden"/>
        <Grid x:Name="FileSelection" Grid.Column="1" Width="100" Background="{DynamicResource AsideSectionBackgroundBrush}">
            <Border x:Name="FileSelectionShadow" Width="12.5" HorizontalAlignment="Left">
                <Border.Background>
                    <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                        <GradientStop Color="#3F000000" Offset="0"/>
                        <GradientStop Color="#00000000" Offset="1"/>
                    </LinearGradientBrush>
                </Border.Background>
            </Border>
            <Button x:Name="OpenFileSelection" Template="{DynamicResource InvisibleButtonTemplate}" HorizontalContentAlignment="Right" Panel.ZIndex="1" Margin="0">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <ei:GoToStateAction StateName="SelectionOpenedState"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
                <TextBlock TextWrapping="Wrap" Text="{Binding OpenActionText, Mode=OneWay, Source={StaticResource LocalStrings}}"  Margin="0,0,23,0" Style="{DynamicResource AsideSectionLabel}"/>
            </Button>
            <local:FileSelectionView x:Name="FileSelectionControl" d:LayoutOverrides="Width" Opacity="0" DataContext="{Binding Files, Mode=OneWay}"/>
        </Grid>
        <Button x:Name="CloseFileSelection" Template="{DynamicResource InvisibleButtonTemplate}" IsHitTestVisible="False" Opacity="0" Margin="0" d:IsHidden="True">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseEnter">
                    <ei:GoToStateAction StateName="SelectionClosedState"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Button>
        <Border x:Name="UserMessage" Background="#BF000000" Visibility="{Binding UserMessenger.IsShowingMessage, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}" Grid.ColumnSpan="2">
            <Border VerticalAlignment="Center" Style="{DynamicResource UserMessageStyle}" Background="#FFE2E2E2" BorderBrush="{x:Null}" BorderThickness="0" MaxWidth="800" HorizontalAlignment="Center" MinWidth="400">
                <Border.Effect>
                    <DropShadowEffect Opacity="0.5" ShadowDepth="10"/>
                </Border.Effect>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <TextBlock TextWrapping="Wrap" Text="{Binding UserMessenger.MessageText, Mode=OneWay}" Margin="0,0,0,10" HorizontalAlignment="Center" MinHeight="58" Style="{DynamicResource TextBlockBase}"/>
                    <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
                        <Border x:Name="OKAction" Style="{DynamicResource ButtonBorderStyle}" Margin="15,0,0,0" Height="50" VerticalAlignment="Top" HorizontalAlignment="Right" Visibility="{Binding UserMessenger.ShowOkButton, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
                            <Border.Effect>
                                <DropShadowEffect Opacity="0.33"/>
                            </Border.Effect>
                            <Button Template="{DynamicResource FlatButtonTemplate}" Command="{Binding UserMessenger.CloseCommand, Mode=OneWay}" Margin="0">
                                <Button.CommandParameter>
                                    <system:String>OK</system:String>
                                </Button.CommandParameter>
                                <Image Height="44" Source="Skins/Images/OK.png"/>
                            </Button>
                        </Border>
                        <Border x:Name="CancelAction" Style="{DynamicResource ButtonBorderStyle}" Margin="15,0,0,0" Height="50" VerticalAlignment="Top" HorizontalAlignment="Right" Visibility="{Binding UserMessenger.ShowCancelButton, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
                            <Border.Effect>
                                <DropShadowEffect Opacity="0.33"/>
                            </Border.Effect>
                            <Button Template="{DynamicResource FlatButtonTemplate}" Command="{Binding UserMessenger.CloseCommand, Mode=OneWay}" Margin="0">
                                <Button.CommandParameter>Cancel</Button.CommandParameter>
                                <Image Height="44" Source="Skins/Images/Cancel.png"/>
                            </Button>
                        </Border>
                    </StackPanel>
                </Grid>
            </Border>
        </Border>
    </Grid>
</UserControl>
Run Code Online (Sandbox Code Playgroud)

Ala*_*lan 25

您需要将混合设计时命名空间标记为可忽略,或者在blend和visual studio之间切换将不起作用.

请参阅在Blend和VS之间来回切换错误

确保以下内容位于XAML名称空间声明中

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
Run Code Online (Sandbox Code Playgroud)

  • 万岁,*又一个* xmlns 命名空间导入,我需要添加到我的项目中的每个 XAML 文件中!(令人沮丧的是,XAML 没有像 Razor 那样的“全局命名空间导入”)。 (2认同)