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

  • Home
  • SEARCH
  • 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 3595582
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T19:52:16+00:00 2026-05-18T19:52:16+00:00

App is in prism/mvvm/mef and uses loading by attribute like StockTraderRI. My shell window

  • 0

App is in prism/mvvm/mef and uses loading by attribute like StockTraderRI.

My shell window contains a DockPanel for a StatusBar, which is global to the shell, not local to each region.

Looks something like this:

<DockPanel>
  <StatusBar DockPanel.Dock="Bottom">
    <StatusBarItem>
      <TextBlock Text="{Binding Source={x:Static bcl:Configuration.Global}, Path=LoggedOn.User}"/>
    </StatusBarItem>
    <StatusBarItem>
      <TextBlock Text="{Binding StateMessage}"/>
    </StatusBarItem>
  </StatusBar>
  <ContentControl x:Name="MainContent" cal:RegionManager.RegionName="MainRegion"/>
</DockPanel>

Binding to a global variable does work well. Now I’d like to bind the StateMessage in the StatusBarItem to the property StateMessage in whatever control is loaded into the MainRegion.
My first guess was to use something like:

<TextBlock Text="{Binding Path=DataContext.StateMessage,Source={StaticResource MainContent}}"/>

But this of course does not work, since MainContent is no StaticResource.

Can anyone point me to a way to bind the Text property to some property of the UserControl loaded into the MainRegion?

  • 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-18T19:52:17+00:00Added an answer on May 18, 2026 at 7:52 pm

    I don’t think you’re going to be able to find a clean way to bind directly to a property in an object in a region. One way you might be able to do this would be to have all Views in the specified region inherit from a common interface, such that they all implement the same Property (say, SystemName). You may be able to bind to a path that includes that property, and use a ValueConverter to change the type from System.Object to the interface type.

    The problem I have with that is that it limits what you can put into the region, and seems to couple the shell with the types displayed in it more than I’d personally like. I’d suggest a different route: since your status bar is part of your shell, have a ViewModel for the shell with your property that the status bar binds to, and that uses an event to track when the status value changes. A few benefits from doing this:

    1. Your event can send any object with any number of properties that your shell can bind to. This lets things other than your status bar also utilize it.
    2. Views that don’t interact with the various objects in your shell don’t have to transmit the event. This lets subviews of a larger component that get displayed in the region not adversely interact with the shell, or implement any interfaces that they don’t need to
    3. It is a well defined mechanism in the Prism framework, and hence an expected way to distribute information

    Note that you could obviously define the event to be whatever you need – I just put in a parameter of type Object, but you’d probably want that to be more specific to your overall needs.

    // Use normal binding for Shell -> ShellViewModel
    public sealed ShellViewModel : INotifyPropertyChanged
    {
       private readonly IEventAggregator = eventAggregator;
    
       public ShellViewModel(IEventAggregator eventAggregator)
       {
          _eventAggregator = eventAggregator;
    
          _eventAggregator.GetEvent<MainRegionViewLoaded>.Subscribe(
             new Action<Object>(HandleMainRegionViewLoaded));
       }
    
       private String _statusName;
       public String StatusName
       {
          get { return _statusName; }
          set
          {
             if (_statusName != value)
             {
                _statusName = value;
                RaisePropertyChanged("StatusName"); // Not showing this...
             }
          }
       }
    
       private void HandleMainRegionViewLoaded(Object param)
       {
          // Not doing all the checking here, such as null, etc.
          var statusName = param as String;
          StatusName = statusName;
       }
    }
    

    Now, all your views have to do is implement IActiveAware, and raise the event when they become Active. Alternatively, you could have the ViewModel’s for your View do this (which is probably better, but would require some additional communication. There’s some explanation here on doing that.).

    public void MainView : UserControl, IActiveAware
    {
    
       private readonly IEventAggregator _eventAggregator;
    
       public MainView(IEventAggregator eventAggregator)
       {
          InitializeComponent();
    
          _eventAggregator = eventAggregator;
       }
    
       private bool _isActive;
       public bool IsActive
       {
          get { return _isActive; }
          set
          {
             if (value)
             {
                _eventAggregator.GetEvent<MainRegionViewLoaded>.Publish(new MainRegionViewLoaded("My Name"));
             }
             _isActive = value;
          }
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

App is in prism/mvvm/mef and uses loading by attribute like StockTraderRI. My shell window
I use prism/mvvm/mef for my app, and loading all Views marked with ViewExport(Region) does
I am building a Prism app with several modules, one of which ( MyModule
I am creating a Composite WPF (Prism) app with several different projects (Shell, modules,
My Prism app needs to insert buttons from several modules into a Shell region.
My app uses a WebRequest at certain points to get pages from itself. This
I am writing an app using the MVVM (Model-View-ViewModel) pattern and am leveraging the
I recently downloaded the MVVM toolkit on codeplex from WPF futures which basically has
Im building a wpf app with the composite application block (prism) V2, and Im
I have a multi-select listbox in a SL3 app using prism and I need

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.