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 6182915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:16:43+00:00 2026-05-24T01:16:43+00:00

I have an Outlook-like WPF UI with navigation on the left, a toolbar on

  • 0

I have an Outlook-like WPF UI with navigation on the left, a toolbar on top, and a status bar at the bottom, all within a DockPanel.

The "main" area of the application is within a DataGrid wich is the LastChild and therefore fills the remaining space and it currently looks like this:

<Grid DockPanel.Dock="Right">
    <Grid.ColumnDefinitions>
        <ColumnDefinition />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition />
    </Grid.RowDefinitions>
    <views:View1 Grid.Column="0" Grid.Row="0"/>
    <views:View2 Grid.Column="0" Grid.Row="0"/>
    <views:View3 Grid.Column="0" Grid.Row="0"/>
    <views:View4 Grid.Column="0" Grid.Row="0"/>
</Grid>

These views are all user controls that have their own ViewModels with Visibility property bound to a property in its ViewModel and controlled by the navigation pane selections. When a navigation pane item is selected the main ViewModel sends a message to ViewModels of the views and upon receiving the message the ViewModels of the views set their Visibility properties accordingly…

Now, this works fine but doesn’t feel right since all the ViewModels of these views are being instantiated on the app start instead of when the related navigation pane is selected bringing up questions about performance and memory usage…

My question is if there is a way of loading each view and its ViewModel "on demand", when the related navigation pane is selected and unloading these views and ViewModels when a different navigation pane is selected without resorting to PRISM/MEF or some other plugin architecture… and, more general how would you approach building an application like this with multiple views/ViewModels "embedded" within the main view?

  • 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-24T01:16:44+00:00Added an answer on May 24, 2026 at 1:16 am

    Here’s what I do:

    First, on your main ViewModel (the one that’s servicing the main window), add a Content property:

    object _content;
    public object Content
    {
        get { return _content; }
        set
        {
            _content = value;
            RaisePropertyChanged("Content");
        }
    }
    

    When the user switches from view to view, set the Content property to the appropriate ViewModel for that view they’ve selected.

    In the main window, then, you can display the current Content ViewModel using a ContentControl:

    <ContentControl Content="{Binding Content}" />
    

    … and somewhere above that, define a DataTemplate for each of the various ViewModels that Content might be set to:

    <DataTemplate DataType="{x:Type vm:FooViewModel}">
        <my:FooUserControl />
    </DataTemplate>
    
    <DataTemplate DataType="{x:Type vm:BarViewModel}">
        <my:BarUserControl />
    </DataTemplate>
    

    So now the ContentControl will be responsible for initializing and displaying each of your UserControls depending on which ViewModel is currently “active”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Outlook 2003 macro written in VBA. I would like to schedule
I have a Listview like the Address book in outlook. and it looks like
I have a WPF application embedded in a Microsoft Outlook 2003 window. Everything is
I have an outlook automation. I would like to use a Word document as
I have created a NavigationPane just like Outlook 2007. In Outlook, when the Pane
We have a large public contacts folder in Outlook called Global Contacts, I'd like
I want to display a custom info bar in my outlook message. Something like
I have a MFC GUI app that has multiple frames (sort of like Outlook'ish
I have an outlook add-in which runs only on the first startup of Outlook,
I have an Outlook style app. So basically I have a sidebar on the

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.