English 中文(简体)
Caliburn。 微观问题: XamlParseException “Cannot set known member{clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro}View.Model”
原标题:Caliburn.Micro question: XamlParseException "Cannot set unknown member {clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro}View.Model "

我真心接受XamlParseException,我对此没有想法。

该电文是“Cannot 个不明成员{clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro}View.Model ......

在这种看法模式中,我有一个可以观察的Collection,即我开始像这样的建筑商:

internal class EntityListScreenViewModel : Screen
{
    public EntityListScreenViewModel()
    {
        var list = new List<Entity>() { new Entity() { Name = "Joe" } };
        this.Entities = new ObservableCollection<Entity>(list);
    }

    public ObservableCollection<Entity> Entities { get; set; }
}

这里的观点是:

<Window x:Class="WpfApp.EntityListScreenView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Height="350" Width="525">
    <Grid>
        <ListBox x:Name="Entities"/>
    </Grid>
</Window>

当我叫WowManager时。 在实体ListScreenViewModel一案中,我获得例外。

如果Ido not在名单上添加一个实体(使用var list=新的清单和编号;意向和; 相反,我没有例外。

Does anybody have any ideas?

<>Update:

我试图将可观察的Collection改变为类型扼杀,并添加了单一体,我没有例外。 我怀疑是卡利伯。 微额贷款在某种程度上试图代表实体加入名单Box。 这也许是什么?

<><>上>

I finally figured out what was really going on... the DefaultItemTemplate in the ConventionManager had some parsed Xaml that was looking for the "Caliburn.Micro" assembly, but I had put the code in with another assembly. Changed the Xaml and the problem went away.

最佳回答

My suspicion is that Caliburn.Micro is somehow looking for a view to represent the Entity in the ListBox

Yes, this is what is going on. By default when you bind a list using a name convention, Caliburn Micro interprets this as you binding to a list of ViewModels; not a list of Entities. This allows you to bind to a list of ViewModels without the need to specify the specific view to use in the ItemTemplate of the ItemsControl and what you end up with is a list of views specific to that ViewModel.

To ensure this doesn t happen, you should be able to just bind manually to the ListBox. If Caliburn Micro sees an ItemsSource binding already, it will ignore the convention.

<ListBox x:Name="Entities" ItemsSource="{Binding Entities}"/>
问题回答

I m not sure, but you can try putting EntityListScreenView in Views namespace and EntityListScreenViewModel in ViewModels namespace - of course if you user "standard" Bootstrapper class.





相关问题
WPF convert 2d mouse click into 3d space

I have several geometry meshes in my Viewport3D, these have bounds of (w:1800, h:500, d:25). When a user clicks in the middle of the mesh, I want the Point3D of (900, 500, 25)... How can I achieve ...

Editing a xaml icons or images

Is it possible to edit a xaml icons or images in the expression design or using other tools? Is it possible to import a xaml images (that e.g you have exported) in the expression designer for editing?...

WPF: writing smoke tests using ViewModels

I am considering to write smoke tests for our WPF application. The question that I am faced is: should we use UI automation( or some other technology that creates a UI script), or is it good enough to ...

WPF - MVVM - NHibernate Validation

Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel. I am using NHibernate to decorate my property on ...

How do WPF Markup Extensions raise compile errors?

Certain markup extensions raise compile errors. For example StaticExtension (x:Static) raises a compile error if the referenced class cannot be found. Anyone know the mechanism for this? Is it baked ...

WPF design-time context menu

I am trying to create a custom wpf control, I m wondering how I can add some design-time features. I ve googled and can t seem to get to my goal. So here s my simple question, how can I add an entry ...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签