Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6761815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:14:12+00:00 2026-05-26T14:14:12+00:00

I have a main window which hosts two views (user controls). One is UserControl1

  • 0

I have a main window which hosts two views (user controls). One is UserControl1 and the other is UserControl2 following a toggle system.

UserControl1 loads first and then the view can be toggled. I wish to launch a window after UserControl1 is loaded.

I am launching views using the messaging pattern and registering the views in app.xaml or MainView.xaml.

How should I proceed?

Xaml for my MainView:

    <Window x:Class="CustomListView.MainView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:CustomView="clr-namespace:CustomListView"
        Title="MainView"
        Width="300"
        Height="300">
    <Window.InputBindings>
        <CustomView:RelayKeyBinding Key="F12"  CommandBinding="{Binding Path=Toggle}"></CustomView:RelayKeyBinding>
    </Window.InputBindings>
    <Window.Resources>
        <DataTemplate x:Key="ExecutionView">
            <CustomView:ExecutionView />
        </DataTemplate>
        <DataTemplate x:Key="ConfigView">
            <CustomView:ConfigView />
        </DataTemplate>
        <Style x:Key="mainContentControlStyle"
               TargetType="{x:Type ContentControl}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=Mode}"
                             Value="1">
                    <Setter Property="ContentTemplate" Value="{StaticResource ResourceKey=ConfigView}" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Path=Mode}"
                             Value="0">
                    <Setter Property="ContentTemplate" Value="{StaticResource ResourceKey=ExecutionView}" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>
    <Grid>
        <ContentControl Content="{Binding}"
                        Style="{StaticResource ResourceKey=mainContentControlStyle}" />        
    </Grid>
</Window>

If you require any more code I’ll be happy to post it.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:14:13+00:00Added an answer on May 26, 2026 at 2:14 pm

    You could use an EventTrigger to convert the Loaded event of the Window into a command execution, then create your window there. This would be my code:

    <UserControl>
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="Loaded">
                <i:InvokeCommandAction Command="{Binding UserControl_LoadedCommand"} />
            </i:EventTrigger>
        </i:Interaction.Triggers>
    </UserControl>
    

    If you are using MVVM Light, this is the code:

    <UserControl>
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="Loaded">
                <Galasoft_MvvmLight_Command:EventToCommand Command="{Binding UserControl_LoadedCommand}"/>
            </i:EventTrigger>
        </i:Interaction.Triggers>
    </UserControl>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings I have a Main Window which will hold multiple User Controls. I will
I have the following code which draws a square on the main window of
In my main window, I have a child control(user control) which contains a text
In my WPF app, I have particular Window which contains, amongst other controls, a
I have a main window (#1) on my webpage from which I open a
I have a UserControl which contains a TextBox . When my main window loads
I have the main thread from which I start a window using invokeLater .
I have a C# windows application which does the following: 1) the main form
I have a class called GUIMain which registers, creates, and shows a main window
Within my main VS solution I have the following 3 projects: The host hosts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.