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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:21:06+00:00 2026-05-31T01:21:06+00:00

I am using Prism 2, trying to add four navigation buttons (First Record, Last

  • 0

I am using Prism 2, trying to add four navigation buttons (First Record, Last Record, Previous Record, Next Record) in shell to be used by modules. I also want these buttons to be disable if active View/ViewModel does not provide these functions.

I tried using events but didn’t know how to achieve my second goal regarding disabling buttons. It seems I need to check current active View/ViewModel to see if they subscribed the click event during View switch. But I think publisher should be unaware of subscriber…

Somehow I tried my own way. I create an IDocNavigation interface which has four method corresponding to my four buttons. At runtime I check modules’ ViewModel if they implemented that interface or not, and change the ICommand on fly. Below is my code. I include one LastRecordCommand only:

public ShellViewModel(Views.Shell shell)
{
this.Shell = shell;
shell.DataContext = this;

shell.MainDocking.ActivePaneChanged += (s, e) =>
{
    if (e.NewPane.Content is UserControl &&
        ((UserControl)e.NewPane.Content).DataContext is IDocumentNavigate)
    {

        IDocumentNavigate vm = ((UserControl)e.NewPane.Content).DataContext as IDocumentNavigate;
        LastRecordCommand = new RelayCommand(x => vm.GotoLastRecord(), x => true);
    }
    else
    {
        LastRecordCommand = new RelayCommand(x => { }, x => false);
    }

};
//...

I feel these are quite ugly. Creating an empty RelayCommand is also stupid. How can I improve ? or how can I achieve disabling command if event is more suitable in my case ?

  • 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-31T01:21:07+00:00Added an answer on May 31, 2026 at 1:21 am

    You can make use of CompositeCommand in prism.

    Define a globally available CompositeCommand

    public static readonly CompositeCommand FirstRecord= new CompositeCommand(true);
    

    Then in your your module view models

        class Module1
         {
    
    
            public DelegateCommand Module1Firstrecord{ get; set; }
            Module1()
            {
              Module1Firstrecord = new DelegateCommand(this.FirstRecord, CanExecute);
            }
    
            private void FirstRecord()
            {
            //do whatever you want
    
            }
    
            private bool CanExecute()
            {
                     return true;
            }
    
            private void Module1_IsActiveChanged(object sender, EventArgs e)
            {
             //Find if your window is acive
             // if it is active Module1Firstrecord.IsActive = true    
             //else false.
            }
    }
    

    With IActiveAware you can handle the active window scenario easily. According to whether your active module have a handler for the command on not the buttons will enable/disable.

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

Sidebar

Related Questions

Using Prism - what is the best way to handle navigation in a WPF
We were building out the next version of an in-house thick-client application using WPF/Prism
I'm using PRISM and I'm trying to get the view, but returns null the
In my application, I'm using Prism and it loads three modules by discovery (Unity).
I am developing a sample using silverlight and prism. I am trying to create
Im using the Prism/Composite Application Library and trying to unit test some code that
I have a main Silverilght project and other modules and I'm using Prism to
I'm using Prism4 and in one of my modules I'm trying to register a
After weeks of using Prism I have been through every kind of navigation methods.
I'm trying to write a datasnap client using Delphi Prism in Visual Studio 2010.

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.