Невозможно просмотреть дизайнер WPF во время разработки - PullRequest
1 голос
/ 09 апреля 2011

Я не могу просмотреть конструктор во время разработки после добавления библиотек GalaSoft.MvvmLight (Runtime версия v2.0.50727, версия 0.0.0.0) и GalaSoft.MvvmLight.Extras (Runtime v2.0.50727, версия 0.0.0.0).Я получаю это исключение во время разработки.

System.IO.FileLoadException Не удалось загрузить файл или сборку 'GalaSoft.MvvmLight, Версия = 0.0.0.0, Культура = нейтральная, PublicKeyToken = null' или однаего зависимостей.Операция не поддерживается.(Исключение из HRESULT: 0x80131515) в System.Reflection.RuntimeAssembly. nLoad (имя_файла AssemblyName, строковое codeBase, доказательство assemblySecurity, место выполнения RuntimeAssembly, StackCrawlMark & ​​stackMark, логическое значение throwOnFileNext.nLoad (AssemblyName имя_файла, строка CodeBase, фактические данные assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark & ​​stackMark, булева throwOnFileNotFound, булева forIntrospection, булевы suppressSecurityChecks) при System.Reflection.RuntimeAssembly.InternalLoadAssemblyName (AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark & ​​stackMark, булевой forIntrospection, булевых suppressSecurityChecks)в System.Reflection.Assembly.Load (AssemblyName assemblyRef) в MS.Internal.Package.VSIsolationProviderService.RemoteReferenceProxy.VsReflectionResolver.GetRuntimeAssembly (AssemblylectionAssembly) в Microsoft.Windows.Design.Metadata.ReflectionMetadataContext.CachingReflectionResolver.GetRuntimeAssembly (AssemblylectionAssembly) в Microsoft.Windows.Design.Metadata.ReflectionMetadataContext.Microsoft.Windows.Design.Microsoft.Windows.Design.Metadata.AttributeTableContainer.d _c.MoveNext () в Microsoft.Windows.Design.Metadata.AttributeTableContainer.GetAttributes (сборка сборки, тип attributeType, Func`2 отражениеMapper) в MS.Internal.ta.ClrAssembly.GetAttributes (ITypeMetadata attributeType) в MS.Internal.Design.Metadata.Xaml.XamlAssembly.get_XmlNamespaceCompatibilityMappings () в Microsoft.Windows.Design.Metadata.Xaml.Xaml.XamlExtensions.GetXmlNamespaceCompatibilityMappings (источник IAssemblyMetadata) в MS.Internal.Design.Metadata..Design.Markup.XmlElement.ConvertToXaml (родительский элемент XamlElement, PrefixScope parentScope, контекст IParseContext, провайдер IMarkupSourceProvider) в MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlSourceDocument.FullDignTocument.FullPirectDocumentTrees.) в MS.Internal.Host.Designer.Load () в MS.Internal.Designer.VSDesigner.Load () в MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedView.Load () в MS.Internal.Designer.VSIsolatedDesigner.фабрика, вид изолированного вида) наMS.Internal.Host.Isolation.IsolatedDesigner.сборка, которая будет помещена в «песочницу» в предыдущих версиях .NET Framework.Этот выпуск .NET Framework по умолчанию не включает политику CAS, поэтому эта загрузка может быть опасной.Если эта загрузка не предназначена для песочницы сборки, включите переключатель loadFromRemoteSources.См. http://go.microsoft.com/fwlink/?LinkId=155569 для получения дополнительной информации.

Я использую .Net Framework 4.0, WPF с c #.

Вот мой код

<Window x:Class="TreeviewApp.MainWindow" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras" 
xmlns:dataGrid="http://schemas.microsoft.com/wpf/2008/toolkit" 
Title="MainWindow" Height="350" Width="525"> 
<Window.Resources> 
<DataTemplate x:Key="DetailTemplate"> 
<TextBlock Text="{Binding Swift_File_Name}"/> 
</DataTemplate> 
<HierarchicalDataTemplate x:Key="MasterTemplate" 
ItemsSource="{ Binding SwiftCol,Mode=TwoWay}" 
ItemTemplate="{StaticResource DetailTemplate}"> 
<HierarchicalDataTemplate.ItemContainerStyle> 
<Style TargetType="TreeViewItem"> 
<Setter Property="IsSelected" Value="{Binding IsExpanded,Mode=TwoWay}"/> 
</Style> 
</HierarchicalDataTemplate.ItemContainerStyle> 
<TextBlock Text="{Binding CITA_Info_Id}"/> 
</HierarchicalDataTemplate> 
<!--<Style TargetType="TreeViewItem"> 
<Setter Property="IsExpanded" Value="True" />
</Style>-->
 
 
 
 
<!--<Style x:Key="myStyle" TargetType="TreeViewItem"> 
<Setter Property="IsExpanded" Value="True" />
</Style>-->
</Window.Resources> 
<Grid> 
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="428,0,0,0" Name="button1" Command="{Binding btnClick}" VerticalAlignment="Top" Width="75" /> 
<TreeView Height="288" HorizontalAlignment="Left" Margin="18,23,0,0" VerticalAlignment="Top" Width="89" 
x:Name="tvCita" ItemsSource="{Binding CitaCol,Mode=TwoWay}" ItemTemplate="{StaticResource MasterTemplate}"> 
<TreeView.ItemContainerStyle> 
<Style TargetType="{x:Type TreeViewItem}"> 
<Setter Property="IsExpanded" Value="True"/> 
</Style> 
</TreeView.ItemContainerStyle> 
<i:Interaction.Triggers> 
<i:EventTrigger EventName="SelectedItemChanged"> 
<cmd:EventToCommand Command="{Binding TreeviewItemClick}" CommandParameter="{Binding SelectedItem, ElementName= tvCita, Mode=OneWay}"/> 
</i:EventTrigger> 
</i:Interaction.Triggers> 
</TreeView> 
<dataGrid:DataGrid Name="dgSwift" Margin="105,24,0,0" ItemsSource="{Binding Path = SwiftCol}" AutoGenerateColumns="False" CanUserAddRows="False"> 
<dataGrid:DataGrid.Columns> 
<dataGrid:DataGridTextColumn Header="0000" Binding="{Binding Path = Line_0000_count}"></dataGrid:DataGridTextColumn> 
<dataGrid:DataGridTextColumn Header="1000" Binding="{Binding Path = Line_1000_count}"></dataGrid:DataGridTextColumn> 
<dataGrid:DataGridTextColumn Header="1100" Binding="{Binding Path = Line_1100_Count}"></dataGrid:DataGridTextColumn> 
<dataGrid:DataGridTextColumn Header="1110" Binding="{Binding Path = Line_1110_count}"></dataGrid:DataGridTextColumn> 
</dataGrid:DataGrid.Columns> 
</dataGrid:DataGrid> 
</Grid> 
</
Window>

Но все функции работают нормально.Подскажите пожалуйста как исправить эту проблему с дизайнером.

1 Ответ

0 голосов
/ 03 сентября 2014

ошибка возникает в функции запуска события.причина дизайн не доступен во время разработки.также некоторая ошибка в проверке данных с этим кодом

<Window x:Class="TreeviewApp.MainWindow" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras" 
xmlns:dataGrid="http://schemas.microsoft.com/wpf/2008/toolkit" 
Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <DataTemplate x:Key="DetailTemplate">
            <TextBlock Text="{Binding Swift_File_Name}"/>
        </DataTemplate>
        <HierarchicalDataTemplate x:Key="MasterTemplate" 
ItemsSource="{ Binding SwiftCol,Mode=TwoWay}" 
ItemTemplate="{StaticResource DetailTemplate}">
            <HierarchicalDataTemplate.ItemContainerStyle>
                <Style TargetType="TreeViewItem">
                    <Setter Property="IsSelected" Value="{Binding IsExpanded,Mode=TwoWay}"/>
                </Style>
            </HierarchicalDataTemplate.ItemContainerStyle>
            <TextBlock Text="{Binding CITA_Info_Id}">           
            </TextBlock>
        </HierarchicalDataTemplate>
    </Window.Resources>
    <Grid>
        <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="428,0,0,0" Name="button1" Command="{Binding btnClick}" VerticalAlignment="Top" Width="75" />
        <TreeView Height="288" HorizontalAlignment="Left" Margin="18,23,0,0" VerticalAlignment="Top" Width="89"  x:Name="tvCita" ItemsSource="{Binding CitaCol,Mode=TwoWay}" ItemTemplate="{StaticResource MasterTemplate}">
            <TreeView.ItemContainerStyle>
                <Style TargetType="{x:Type TreeViewItem}">
                    <Setter Property="IsExpanded" Value="True"/>
                </Style>
            </TreeView.ItemContainerStyle>
            <!--<i:Interaction.Triggers>
                --><!--<i:EventTrigger EventName="SelectedItemChanged">
                    <cmd:EventToCommand Command="{Binding TreeviewItemClick}" CommandParameter="{Binding SelectedItem, ElementName= tvCita, Mode=OneWay}"/>
                </i:EventTrigger>--><!--
            </i:Interaction.Triggers>-->
        </TreeView>
        <DataGrid Name="dgSwift" Margin="105,24,0,0" ItemsSource="{Binding Path = SwiftCol}" AutoGenerateColumns="False" CanUserAddRows="False">
            <DataGrid.Columns >
                    <DataGridTextColumn Header="0000" Binding="{Binding Path = Line_0000_count}"></DataGridTextColumn>
                    <DataGridTextColumn Header="1000" Binding="{Binding Path = Line_1000_count}"></DataGridTextColumn>
                    <DataGridTextColumn Header="1100" Binding="{Binding Path = Line_1100_Count}"></DataGridTextColumn>
                    <DataGridTextColumn Header="1110" Binding="{Binding Path = Line_1110_count}"></DataGridTextColumn>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</Window>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...