Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在Visual studio 2008中尝试编辑UI时发生WPF设计器异常_C#_Wpf_Visual Studio 2008_Data Binding_Xaml - Fatal编程技术网

C# 在Visual studio 2008中尝试编辑UI时发生WPF设计器异常

C# 在Visual studio 2008中尝试编辑UI时发生WPF设计器异常,c#,wpf,visual-studio-2008,data-binding,xaml,C#,Wpf,Visual Studio 2008,Data Binding,Xaml,我的机器上安装了带有.NET3.5SP1的VS2008,我编写了一个带有两个ListView和数据绑定的简单应用程序,我的应用程序编译得很好,我能够运行它,但当我试图打开designer编辑控件时,我得到了以下错误。 我不明白为什么会这样。任何想法…请参阅此错误消息下面的xaml <Grid Name="pngrid_Base" Height="auto" Width="auto" Background="Beige"> <Grid.ColumnDefinitions&

我的机器上安装了带有.NET3.5SP1的VS2008,我编写了一个带有两个ListView和数据绑定的简单应用程序,我的应用程序编译得很好,我能够运行它,但当我试图打开designer编辑控件时,我得到了以下错误。 我不明白为什么会这样。任何想法…请参阅此错误消息下面的xaml

<Grid Name="pngrid_Base" Height="auto" Width="auto" Background="Beige">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="auto" MinWidth="221"></ColumnDefinition>
        <ColumnDefinition Width="auto" MinWidth="1" MaxWidth="1"></ColumnDefinition>
        <ColumnDefinition Width="auto"></ColumnDefinition>
    </Grid.ColumnDefinitions>
        <Grid Name="pngrid_BaseForAll" Grid.Column="0" Width="auto" HorizontalAlignment="Left" Background="#FFD8E4F8">
     <Grid.RowDefinitions>
        <RowDefinition Height="30*"/>
        <RowDefinition Height="164*" />
        <RowDefinition Height="35*" />
        <RowDefinition Height="164*" />
        <RowDefinition Height="40*" />
    </Grid.RowDefinitions>
        <ListView  Name="lstview_Unack" Grid.Row="1" Margin="2,0,0,0" SelectionMode="Extended"  LostFocus="lstview_Unack_LostFocus" 
                                                                                                MouseRightButtonDown="lstview_Unack_MouseRightButtonDown">

            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>
        <Button Grid.Row="2" HorizontalAlignment="Left" Margin="24,14,0,5" Name="btnFreeze">Freeze</Button>
            <Button Grid.Row="2" HorizontalAlignment="Left" Margin="12,7,0,5" Name="btnAcknowledge" Width="96">Acknowledge</Button>
        <ListView  Name = "lstview_Ack" Grid.Row="3" Margin="2,1,0,0" LostFocus="lstview_Ack_LostFocus" SelectionMode="Extended" MouseRightButtonDown="lstview_Ack_MouseRightButtonDown">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />                            
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>


        <Button Grid.Row="4" HorizontalAlignment="Left" Margin="16,12,0,7" Name="Clear" Width="78">Clear</Button>
    <TextBox Margin="110,6,32,5" Name="FilterText" TextChanged="FilterText_TextChanged" />
    <ComboBox HorizontalAlignment="Left" Margin="14,5,0,4" Name="comboColumnList" Width="94" />
</Grid>
    <GridSplitter Grid.Column="1" Name="gridSplitter1" Width="2" HorizontalContentAlignment="Center" VerticalContentAlignment="Stretch" HorizontalAlignment="Left" Background="Azure" />
    <Grid Name="pnGridForTreeView" Grid.Column="2" Width="200" Grid.ColumnSpan="2">
        <my:TrinityDeviceTree  x:Name ="m_objDeviceTree" Height="auto" Width="auto">

        </my:TrinityDeviceTree>
    </Grid>

</Grid>
程序集“PresentationFramework,版本=3.0.0.0,区域性=中性,PublicKeyToken=31bf3856ad364e35”中的类型“MS.Internal.Permissions.UserInitiatedNavigationPermission”未标记为可序列化。 at System.Runtime.Serialization.FormatterServices.InternalGetSerializationMembers(RuntimeType类型) at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(类型,StreamingContext上下文) 在System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()中 在System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(对象obj、ISurrogateSelector代理选择器、StreamingContext上下文、SeroObjectInfo初始化SeroObjectInfo初始化、FormatterConverter转换器、ObjectWriter ObjectWriter) 在System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serializate(对象obj、ISurrogateSelector代理选择器、StreamingContext上下文、SeroObjectInfo init SeroObjectInfo init、FormatterConverter转换器、ObjectWriter ObjectWriter) 在System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo,NameInfo memberNameInfo,NameInfo typeNameInfo) 在System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serializate(对象图,头[]inHeaders,\uu BinaryWriter serWriter,布尔fCheck) 在System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serializate(流序列化流,对象图,头[]头,布尔fCheck) 在System.Runtime.Remoting.Channels.CrossAppDomainSerializer.SerializeObject(对象obj,MemoryStream stm) 在System.AppDomain.Serialize处(对象o) 位于System.AppDomain.MarshallObject(对象o) 在System.Threading.CompressedStack.GetDomainCompressedStack(安全压缩堆栈句柄压缩堆栈,Int32索引) 在System.Security.PermissionListSet.CreateCompressedState(CompressedStack cs,CompressedStack innerCS) at System.Threading.CompressedStack.CompleteConstruction(压缩堆栈内部CS) at System.Threading.CompressedStack.GetCompressedStack(堆栈爬网标记和堆栈标记) 在System.Security.SecurityContext.Capture(ExecutionContext currThreadEC、StackScrawMark和stackMark) 在System.Threading.ExecutionContext.Capture(StackScrawlMark和stackMark)中 在System.Threading.ExecutionContext.Capture()中 位于System.Windows.Threading.Dispatcher.BeginInvokeImpl(DispatcherPriority优先级、委托方法、对象参数、布尔isSingleParameter) 位于System.Windows.Threading.Dispatcher.BeginInvoke(DispatcherPriority优先级、委托方法、对象参数) 在System.Windows.Input.CommandManager.RaiseRequerySuggested()中 在System.Windows.Input.CommandManager.InvalidateRequestSuggested()中 位于Microsoft.Windows.Design.Interaction.Tool.TaskCollection.InsertItem(Int32索引,任务项) 位于System.Collections.ObjectModel.Collection`1.Add(T项) 在Microsoft.Windows.Design.Interaction.SelectionTool..ctor()上 在MS.Internal.Providers.VSActiveToolProvider.SelectionToolFactory.TryCreateTool[T](T&tool) 位于MS.Internal.Host.ToolSubsystem.ActivateTool(工具工厂工具工厂) 位于MS.Internal.Host.ToolSubsystem..ctor(编辑上下文编辑上下文,设计上下文设计上下文) 在MS.Internal.Host.Designer.Load()处 在MS.Internal.Designer.VSDesigner.Load()处 在MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedView.Load()中 在MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedDesignerFactory.Load(IsolatedView视图)中 位于MS.Internal.Host.IsolatedDesigner.bootstrapRoxy.LoadDesigner(IsolatedDesigner工厂,IsolatedView视图) 位于MS.Internal.Host.IsolatedDesigner.bootstrapRoxy.LoadDesigner(IsolatedDesigner工厂,IsolatedView视图) 在MS.Internal.Host.IsolatedDesigner.Load()处 在MS.Internal.Designer.DesignerPane.LoadDesignerView()上

<Grid Name="pngrid_Base" Height="auto" Width="auto" Background="Beige">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="auto" MinWidth="221"></ColumnDefinition>
        <ColumnDefinition Width="auto" MinWidth="1" MaxWidth="1"></ColumnDefinition>
        <ColumnDefinition Width="auto"></ColumnDefinition>
    </Grid.ColumnDefinitions>
        <Grid Name="pngrid_BaseForAll" Grid.Column="0" Width="auto" HorizontalAlignment="Left" Background="#FFD8E4F8">
     <Grid.RowDefinitions>
        <RowDefinition Height="30*"/>
        <RowDefinition Height="164*" />
        <RowDefinition Height="35*" />
        <RowDefinition Height="164*" />
        <RowDefinition Height="40*" />
    </Grid.RowDefinitions>
        <ListView  Name="lstview_Unack" Grid.Row="1" Margin="2,0,0,0" SelectionMode="Extended"  LostFocus="lstview_Unack_LostFocus" 
                                                                                                MouseRightButtonDown="lstview_Unack_MouseRightButtonDown">

            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>
        <Button Grid.Row="2" HorizontalAlignment="Left" Margin="24,14,0,5" Name="btnFreeze">Freeze</Button>
            <Button Grid.Row="2" HorizontalAlignment="Left" Margin="12,7,0,5" Name="btnAcknowledge" Width="96">Acknowledge</Button>
        <ListView  Name = "lstview_Ack" Grid.Row="3" Margin="2,1,0,0" LostFocus="lstview_Ack_LostFocus" SelectionMode="Extended" MouseRightButtonDown="lstview_Ack_MouseRightButtonDown">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />                            
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>


        <Button Grid.Row="4" HorizontalAlignment="Left" Margin="16,12,0,7" Name="Clear" Width="78">Clear</Button>
    <TextBox Margin="110,6,32,5" Name="FilterText" TextChanged="FilterText_TextChanged" />
    <ComboBox HorizontalAlignment="Left" Margin="14,5,0,4" Name="comboColumnList" Width="94" />
</Grid>
    <GridSplitter Grid.Column="1" Name="gridSplitter1" Width="2" HorizontalContentAlignment="Center" VerticalContentAlignment="Stretch" HorizontalAlignment="Left" Background="Azure" />
    <Grid Name="pnGridForTreeView" Grid.Column="2" Width="200" Grid.ColumnSpan="2">
        <my:TrinityDeviceTree  x:Name ="m_objDeviceTree" Height="auto" Width="auto">

        </my:TrinityDeviceTree>
    </Grid>

</Grid>
XAML:

<Grid Name="pngrid_Base" Height="auto" Width="auto" Background="Beige">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="auto" MinWidth="221"></ColumnDefinition>
        <ColumnDefinition Width="auto" MinWidth="1" MaxWidth="1"></ColumnDefinition>
        <ColumnDefinition Width="auto"></ColumnDefinition>
    </Grid.ColumnDefinitions>
        <Grid Name="pngrid_BaseForAll" Grid.Column="0" Width="auto" HorizontalAlignment="Left" Background="#FFD8E4F8">
     <Grid.RowDefinitions>
        <RowDefinition Height="30*"/>
        <RowDefinition Height="164*" />
        <RowDefinition Height="35*" />
        <RowDefinition Height="164*" />
        <RowDefinition Height="40*" />
    </Grid.RowDefinitions>
        <ListView  Name="lstview_Unack" Grid.Row="1" Margin="2,0,0,0" SelectionMode="Extended"  LostFocus="lstview_Unack_LostFocus" 
                                                                                                MouseRightButtonDown="lstview_Unack_MouseRightButtonDown">

            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>
        <Button Grid.Row="2" HorizontalAlignment="Left" Margin="24,14,0,5" Name="btnFreeze">Freeze</Button>
            <Button Grid.Row="2" HorizontalAlignment="Left" Margin="12,7,0,5" Name="btnAcknowledge" Width="96">Acknowledge</Button>
        <ListView  Name = "lstview_Ack" Grid.Row="3" Margin="2,1,0,0" LostFocus="lstview_Ack_LostFocus" SelectionMode="Extended" MouseRightButtonDown="lstview_Ack_MouseRightButtonDown">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />                            
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>


        <Button Grid.Row="4" HorizontalAlignment="Left" Margin="16,12,0,7" Name="Clear" Width="78">Clear</Button>
    <TextBox Margin="110,6,32,5" Name="FilterText" TextChanged="FilterText_TextChanged" />
    <ComboBox HorizontalAlignment="Left" Margin="14,5,0,4" Name="comboColumnList" Width="94" />
</Grid>
    <GridSplitter Grid.Column="1" Name="gridSplitter1" Width="2" HorizontalContentAlignment="Center" VerticalContentAlignment="Stretch" HorizontalAlignment="Left" Background="Azure" />
    <Grid Name="pnGridForTreeView" Grid.Column="2" Width="200" Grid.ColumnSpan="2">
        <my:TrinityDeviceTree  x:Name ="m_objDeviceTree" Height="auto" Width="auto">

        </my:TrinityDeviceTree>
    </Grid>

</Grid>

<Grid Name="pngrid_Base" Height="auto" Width="auto" Background="Beige">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="auto" MinWidth="221"></ColumnDefinition>
        <ColumnDefinition Width="auto" MinWidth="1" MaxWidth="1"></ColumnDefinition>
        <ColumnDefinition Width="auto"></ColumnDefinition>
    </Grid.ColumnDefinitions>
        <Grid Name="pngrid_BaseForAll" Grid.Column="0" Width="auto" HorizontalAlignment="Left" Background="#FFD8E4F8">
     <Grid.RowDefinitions>
        <RowDefinition Height="30*"/>
        <RowDefinition Height="164*" />
        <RowDefinition Height="35*" />
        <RowDefinition Height="164*" />
        <RowDefinition Height="40*" />
    </Grid.RowDefinitions>
        <ListView  Name="lstview_Unack" Grid.Row="1" Margin="2,0,0,0" SelectionMode="Extended"  LostFocus="lstview_Unack_LostFocus" 
                                                                                                MouseRightButtonDown="lstview_Unack_MouseRightButtonDown">

            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>
        <Button Grid.Row="2" HorizontalAlignment="Left" Margin="24,14,0,5" Name="btnFreeze">Freeze</Button>
            <Button Grid.Row="2" HorizontalAlignment="Left" Margin="12,7,0,5" Name="btnAcknowledge" Width="96">Acknowledge</Button>
        <ListView  Name = "lstview_Ack" Grid.Row="3" Margin="2,1,0,0" LostFocus="lstview_Ack_LostFocus" SelectionMode="Extended" MouseRightButtonDown="lstview_Ack_MouseRightButtonDown">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />                            
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>


        <Button Grid.Row="4" HorizontalAlignment="Left" Margin="16,12,0,7" Name="Clear" Width="78">Clear</Button>
    <TextBox Margin="110,6,32,5" Name="FilterText" TextChanged="FilterText_TextChanged" />
    <ComboBox HorizontalAlignment="Left" Margin="14,5,0,4" Name="comboColumnList" Width="94" />
</Grid>
    <GridSplitter Grid.Column="1" Name="gridSplitter1" Width="2" HorizontalContentAlignment="Center" VerticalContentAlignment="Stretch" HorizontalAlignment="Left" Background="Azure" />
    <Grid Name="pnGridForTreeView" Grid.Column="2" Width="200" Grid.ColumnSpan="2">
        <my:TrinityDeviceTree  x:Name ="m_objDeviceTree" Height="auto" Width="auto">

        </my:TrinityDeviceTree>
    </Grid>

</Grid>

冻结
承认
清楚的

我已经用.NET 3.5 SP1在VS2008内部测试了您的代码,如果我删除TrinityDeviceTree的声明,它可以与设计器一起正常工作。
<Grid Name="pngrid_Base" Height="auto" Width="auto" Background="Beige">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="auto" MinWidth="221"></ColumnDefinition>
        <ColumnDefinition Width="auto" MinWidth="1" MaxWidth="1"></ColumnDefinition>
        <ColumnDefinition Width="auto"></ColumnDefinition>
    </Grid.ColumnDefinitions>
        <Grid Name="pngrid_BaseForAll" Grid.Column="0" Width="auto" HorizontalAlignment="Left" Background="#FFD8E4F8">
     <Grid.RowDefinitions>
        <RowDefinition Height="30*"/>
        <RowDefinition Height="164*" />
        <RowDefinition Height="35*" />
        <RowDefinition Height="164*" />
        <RowDefinition Height="40*" />
    </Grid.RowDefinitions>
        <ListView  Name="lstview_Unack" Grid.Row="1" Margin="2,0,0,0" SelectionMode="Extended"  LostFocus="lstview_Unack_LostFocus" 
                                                                                                MouseRightButtonDown="lstview_Unack_MouseRightButtonDown">

            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>
        <Button Grid.Row="2" HorizontalAlignment="Left" Margin="24,14,0,5" Name="btnFreeze">Freeze</Button>
            <Button Grid.Row="2" HorizontalAlignment="Left" Margin="12,7,0,5" Name="btnAcknowledge" Width="96">Acknowledge</Button>
        <ListView  Name = "lstview_Ack" Grid.Row="3" Margin="2,1,0,0" LostFocus="lstview_Ack_LostFocus" SelectionMode="Extended" MouseRightButtonDown="lstview_Ack_MouseRightButtonDown">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />                            
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>


        <Button Grid.Row="4" HorizontalAlignment="Left" Margin="16,12,0,7" Name="Clear" Width="78">Clear</Button>
    <TextBox Margin="110,6,32,5" Name="FilterText" TextChanged="FilterText_TextChanged" />
    <ComboBox HorizontalAlignment="Left" Margin="14,5,0,4" Name="comboColumnList" Width="94" />
</Grid>
    <GridSplitter Grid.Column="1" Name="gridSplitter1" Width="2" HorizontalContentAlignment="Center" VerticalContentAlignment="Stretch" HorizontalAlignment="Left" Background="Azure" />
    <Grid Name="pnGridForTreeView" Grid.Column="2" Width="200" Grid.ColumnSpan="2">
        <my:TrinityDeviceTree  x:Name ="m_objDeviceTree" Height="auto" Width="auto">

        </my:TrinityDeviceTree>
    </Grid>

</Grid>

也许你应该检查一下这个用户控件,看看有没有错误。另外,请尝试清理您的项目并进行重建,有时它可以解决visual designer的问题。

出现此类错误的原因是什么……似乎此错误非常常见,但解决方案不是……我已经看到很多帖子都有此错误
<Grid Name="pngrid_Base" Height="auto" Width="auto" Background="Beige">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="auto" MinWidth="221"></ColumnDefinition>
        <ColumnDefinition Width="auto" MinWidth="1" MaxWidth="1"></ColumnDefinition>
        <ColumnDefinition Width="auto"></ColumnDefinition>
    </Grid.ColumnDefinitions>
        <Grid Name="pngrid_BaseForAll" Grid.Column="0" Width="auto" HorizontalAlignment="Left" Background="#FFD8E4F8">
     <Grid.RowDefinitions>
        <RowDefinition Height="30*"/>
        <RowDefinition Height="164*" />
        <RowDefinition Height="35*" />
        <RowDefinition Height="164*" />
        <RowDefinition Height="40*" />
    </Grid.RowDefinitions>
        <ListView  Name="lstview_Unack" Grid.Row="1" Margin="2,0,0,0" SelectionMode="Extended"  LostFocus="lstview_Unack_LostFocus" 
                                                                                                MouseRightButtonDown="lstview_Unack_MouseRightButtonDown">

            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>
        <Button Grid.Row="2" HorizontalAlignment="Left" Margin="24,14,0,5" Name="btnFreeze">Freeze</Button>
            <Button Grid.Row="2" HorizontalAlignment="Left" Margin="12,7,0,5" Name="btnAcknowledge" Width="96">Acknowledge</Button>
        <ListView  Name = "lstview_Ack" Grid.Row="3" Margin="2,1,0,0" LostFocus="lstview_Ack_LostFocus" SelectionMode="Extended" MouseRightButtonDown="lstview_Ack_MouseRightButtonDown">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />                            
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>


        <Button Grid.Row="4" HorizontalAlignment="Left" Margin="16,12,0,7" Name="Clear" Width="78">Clear</Button>
    <TextBox Margin="110,6,32,5" Name="FilterText" TextChanged="FilterText_TextChanged" />
    <ComboBox HorizontalAlignment="Left" Margin="14,5,0,4" Name="comboColumnList" Width="94" />
</Grid>
    <GridSplitter Grid.Column="1" Name="gridSplitter1" Width="2" HorizontalContentAlignment="Center" VerticalContentAlignment="Stretch" HorizontalAlignment="Left" Background="Azure" />
    <Grid Name="pnGridForTreeView" Grid.Column="2" Width="200" Grid.ColumnSpan="2">
        <my:TrinityDeviceTree  x:Name ="m_objDeviceTree" Height="auto" Width="auto">

        </my:TrinityDeviceTree>
    </Grid>

</Grid>