棱镜导致的错误:"System.Windows.Markup.XamlParseException"
Error because of Prism : "System.Windows.Markup.XamlParseException"
我有一个包含四个项目的解决方案,如:
- BridgeConcrete.BL
- BridgeConcrete.DAL
- BridgeConcrete.ViewModel
- BridgeConcrete.WPF
我正在使用:
- Microsoft.Practices.Prism.Mvvm 版本 1.1.1.0
- Microsoft.Practices.Prism.Mvvm.桌面版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。用户控件: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>
- MainWindow.xaml:
我称用户控件为:
<local:ProjectView Margin="0,0,0.4,5.4"/>
错误是:
System.Windows.Markup.XamlParseException: 'The method or operation is not implemented.'
内部异常
NotImplementedException: 方法或操作未实现。
我做了很多搜索,但我找不到解决方案,除了我必须调试。所以,我这样做了,我发现问题出在 Prism 上。
当我删除了 Prism 的继承时,它运行良好。
问题:
这里有什么问题,请问如何解决
您可能正在调用一个旨在让您覆盖的虚函数。该方法将抛出 NotImplementedException
(通常开发人员在他们希望人们实现的虚拟方法中抛出此异常,而不是让它们 abstract
)
如果您可以附加堆栈跟踪,它可能有助于指出正确的方向。
我有一个包含四个项目的解决方案,如:
- BridgeConcrete.BL
- BridgeConcrete.DAL
- BridgeConcrete.ViewModel
- BridgeConcrete.WPF
我正在使用:
- Microsoft.Practices.Prism.Mvvm 版本 1.1.1.0
- Microsoft.Practices.Prism.Mvvm.桌面版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。用户控件: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>
- MainWindow.xaml:
我称用户控件为:
<local:ProjectView Margin="0,0,0.4,5.4"/>
错误是:
System.Windows.Markup.XamlParseException: 'The method or operation is not implemented.'
内部异常
NotImplementedException: 方法或操作未实现。
我做了很多搜索,但我找不到解决方案,除了我必须调试。所以,我这样做了,我发现问题出在 Prism 上。
当我删除了 Prism 的继承时,它运行良好。
问题:
这里有什么问题,请问如何解决
您可能正在调用一个旨在让您覆盖的虚函数。该方法将抛出 NotImplementedException
(通常开发人员在他们希望人们实现的虚拟方法中抛出此异常,而不是让它们 abstract
)
如果您可以附加堆栈跟踪,它可能有助于指出正确的方向。