由于Prism错误:“System.Windows.Markup.XamlParseException”

时间:2017-04-23 10:51:44

标签: c# visual-studio mvvm prism

我有一个包含四个项目的解决方案,如:

  1. BridgeConcrete.BL
  2. BridgeConcrete.DAL
  3. BridgeConcrete.ViewModel
  4. BridgeConcrete.WPF
  5. 我正在使用:

    • Microsoft.Practices.Prism.Mvvm版本1.1.1.0
    • Microsoft.Practices.Prism.Mvvm.Desktop版本1.1.1.0
    • Microsoft.Practices.Prism.SharedInterfaces版本1.1.1.0

    BridgeConcrete.BL还没有。

    BridgeConcrete.DAL具有:

    public class Project
    {
        public Project()
        {
            AddedBy = 1;
            AddedDate = System.DateTime.Now;
        }
        public int Id { get; set; }
        public string Name { get; set; }
    
        public DateTime AddedDate { get; set; }
        public int AddedBy { get; set; }
    
        public DateTime? ModifiedDate { get; set; }
        public int? ModifiedBy { get; set; }
    
    
        // Calculated Fields
        public int BridgeCount { get; private set; }
    }
    

    BridgeConcrete.ViewModel具有:

    public class ProjectViewModel : BindableBase
    {
        private IEnumerable<Project> _projects;
        public IEnumerable<Project> Projects
        {
            get { return _projects; }
            set { SetProperty(ref _projects, value); }
        }
    
        private Project _selectedRecord;
        public Project SelectedRecord
        {
            get { return _selectedRecord; }
            set { SetProperty(ref _selectedRecord, value); }
        }
    
        public ProjectViewModel()
        {
            SelectedRecord = new Project() { Id = 1, Name = "Test 1" };
        }
    }
    

    在BridgeConcrete.WPF中,我有:

    1。 UserControl:ProjectView.xaml

    <UserControl
        x:Class="BridgeConcrete.WPF.ProjectView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:vm="clr-namespace:BridgeConcrete.ViewModel;assembly=BridgeConcrete.ViewModel"
        mc:Ignorable="d"
        d:DesignWidth="299.257" Height="140.059">
    
        <UserControl.DataContext>
            <vm:ProjectViewModel/>
        </UserControl.DataContext>
    
        <Grid >
            <Label Content="Project ID:" HorizontalAlignment="Left" Margin="10,22,0,0" VerticalAlignment="Top"/>
            <TextBox HorizontalAlignment="Left" Height="23" Margin="98,25,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="78" IsEnabled="False"                
                        Text="{Binding SelectedRecord.Id }"/>
    
            <Label Content="Project Name:" HorizontalAlignment="Left" Margin="10,48,0,0" VerticalAlignment="Top"/>
            <TextBox HorizontalAlignment="Left" Height="23" Margin="99,53,0,0" TextWrapping="Wrap" Text="{Binding SelectedRecord.Name}" VerticalAlignment="Top" Width="145" />
        </Grid>
    
    </UserControl>
    
    1. MainWindow.xaml:
    2. 我将用户控件称为:

      <local:ProjectView Margin="0,0,0.4,5.4"/>
      

      错误是:

      System.Windows.Markup.XamlParseException:'方法或操作未实现。'

      内部异常

      NotImplementedException:未实现方法或操作。

      我做了很多搜索,但除了我必须调试之外,我找不到解决方案。所以,我做到了,我发现问题来自Prism。

      当我删除了Prism的继承时,它运作良好。

      问题:

      这里有什么问题,如何解决这个问题,请

1 个答案:

答案 0 :(得分:1)

您可能正在调用一个旨在覆盖的虚拟函数。该方法将抛出NotImplementedException(通常开发人员将此异常抛在他们希望人们实现的虚拟方法中,而不是使它们abstract

如果您可以附加堆栈跟踪,则可能有助于指向正确的方向。