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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:59:27+00:00 2026-06-13T04:59:27+00:00

I want to know what the advantage are using the relay command to call

  • 0

I want to know what the advantage are using the relay command to call functions that refresh the screen. In my application I have the following relay command setup.

private RelayCommand _refreshSitesCommand;
    public RelayCommand RefreshSitesCommand
    {
        get { return _refreshSitesCommand ?? (_refreshSitesCommand = new RelayCommand(RefreshSites)); }
    }

    private RelayCommand _refreshProvidersCommand;
    public RelayCommand RefreshProvidersCommand
    {
        get { return _refreshProvidersCommand ?? (_refreshProvidersCommand = new RelayCommand(RefreshProviders)); }
    }

    private async void RefreshSites()
    {
        var sitesStats = await _dataService.GetSiteStats();

        if (sitesStats != null)
        {
            SiteStats.Clear();

            foreach (var site in sitesStats)
            {
                SiteStats.Add(new SiteStatsViewModel(site));
            }

            SelectedSite = SiteStats[0];
        }
    }

    private async void RefreshProviders()
    {
        var providers = await _dataService.GetProviders();

        if (providers != null)
        {
            Providers.Clear();

            foreach (var provider in providers)
            {
                Providers.Add(new ProviderViewModel(provider));
            }

            SelectedProvider = Providers[0];
        }
    }

Then in my code I have the following calls to execute it.

RefreshProvidersCommand.Execute(null);
RefreshSitesCommand.Execute(null);

So why is that better than just calling the RefreshSites and RefreshProviders functions. Then I would not need the code for the RelayCommand objects. Other than exposing the functionality of the 2 private functions, what benefit does using the RelayCommand object have over just making the functions public and calling them.

  • 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-06-13T04:59:28+00:00Added an answer on June 13, 2026 at 4:59 am

    Because you can bind to a Command in your view. You can’t bind to methods in your views (well you can but binding to Commands is much cleaner)

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

Sidebar

Related Questions

I have an application that is fetching several e-commerce websites using Curl, looking for
I have an android app it displays web view.I want know the app idle
want to know why String behaves like value type while using ==. String s1
I have seen that google music is using one image for all the small
I have been reading about git rebase and the advantage of using a rebase
I have a very large list of items (~2 millions) that I want to
I know that ASP.NET controls such as the button have the postback event model.
I'm using Advantage Database Server 9.10, and I want to append a text to
I want to know right way to use DataReader. (C# and Advantage Database) Assuming
I want to know about the advantages and disadvantages of URL masking. Does it

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.