question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stylet.StyletInvalidViewTypeException

See original GitHub issue

Hello. I get this exception says that View doesn’t derive from the Window class. But I call .ShowDialog from Conductor<IScreen>.Collection.OneActive derives from Window. Window’s ViewModel:

public class MainViewModel : Conductor<IScreen>.Collection.OneActive
    {
        private ErrorBoxViewModel errorBox;
        private readonly IWindowManager windowManager;

        public MainViewModel(IWindowManager windowManager)
        {
            this.windowManager = windowManager;
        }

        public void ShowError(string message)
        {
            if (errorBox != null)
                errorBox.RequestClose();
            errorBox = new ErrorBoxViewModel(message);
            this.windowManager.ShowDialog(errorBox);
        }
    }

In another view model derives from UserControl I call: (Conductor as MainViewModel).ShowError("some string");

ErrorBoxViewModel view model derives from UserControl as well:

public class ErrorBoxViewModel : Screen
    {
        public string Message { get; private set; }

        public ErrorBoxViewModel(string message)
        {
            this.Message = message;
        }

        protected override void OnActivate()
        {
            base.OnActivate();
        }

        protected override void OnDeactivate()
        {
            base.OnDeactivate();
        }

        public void CloseWithSuccess()
        {
            this.RequestClose(true);
        }
    }

Any Idea what’s wrong?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
canton7commented, Feb 25, 2017

So not as a Window at all?

You’ll want to put both the TabControl and the overlay in the same Grid, so that the overlay is placed on top of the TabControl. Something like this (untested, might have errors):

<Window x:Class="Your.MainView" ....>
    <Grid>
        <!-- Display both the overlay and the TabControl, with the overlay on top of the TabControl -->
        <TabControl .....>
        </TabControl>
        <ContentControl s:View.Model="{Binding Overlay}"/>
    </Grid>
</Window>
public class MainViewModel : Conductor<IScreen>.Collection.OneActive
{
    private IScreen _overlay;
    public IScreen Overlay
    {
        get { return this._overlay; }
        private set { this.SetAndNotify(ref this._overlay, value); }
    }

    public void ShowOverlay()
    {    
        this.Overlay = new SomeViewModel();
    }
}
0reactions
canton7commented, Feb 25, 2017

Cool!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ViewManager.cs - canton7/Stylet
A very lightweight but powerful ViewModel-First MVVM framework for WPF for .NET Framework and .NET Core, inspired by Caliburn.Micro.
Read more >
RecyclerView Adapter is repeating values at wrong places
I am displaying 17 CardViews. I am using RecyclerView to achieve the same. Each CardView shows a common data (format). Depending on data ......
Read more >
Give an explicit error message when unsupported view type used
JenkinsJobsException : Unrecognized view type: list-view (supported types are: list, pipeline) Change-Id: ... tests/xml_config/exceptions/invalid_view.yaml.
Read more >
SubtitleView.ViewType
ShowBuffering · SubtitleView.ViewType. androidx.media3.ui.leanback ... Invalid · PagingSource.LoadResult. ... androidx.wear.watchface.style.
Read more >
InvalidTemplateStructureException Class | Documents for ...
The exception that is thrown when a data template structure is invalid. Object Model. Syntax. Visual Basic; C#.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found