Skip to content

Cannot find view for ViewModels create with interceptor #900

@1130685535

Description

@1130685535

I have a MyViewModel class as follows:

public class MyViewModel : Screen, ITransientDependency
{
    [ReapeatClick]
    public void Save()
    {
    }
}

The [ReapeatClick] method attribute uses an interceptor.

In a method ShowView():

private void ShowView()
{
    var vm = IoC.Get<MyViewModel>();
    IWindowManager windowManager = IoC.Get<IWindowManager>();
    var dialogResult = await windowManager.ShowDialogAsync(vm);
}

When obtaining the class with an interceptor using the IoC container: var vm = IoC.Get();, the type of vm becomes Castle.Proxies.MyViewModelProxy. However, the View’s name is MyView, which prevents the View from being matched with the ViewModel.
I tried the following configuration but still could not locate the View:

ViewLocator.AddNamespaceMapping("Castle.Proxies.*", _viewAssemblyName);
ViewLocator.NameTransformer.AddRule(@"ViewModelProxy$", "View");

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions