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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:54:36+00:00 2026-05-25T23:54:36+00:00

Assuming a code like below, public class SomeViewModel{ ICommand ReloadCommand{get…} ICommand SaveCommand{get..} } //SomeView.xaml

  • 0

Assuming a code like below,

public class SomeViewModel{
      ICommand ReloadCommand{get...}
      ICommand SaveCommand{get..}
}

//SomeView.xaml
<SomeCustomControl Reload="ReloadCommand" Save="SaveCommand" /> //NOT SURE HOW??

//SomeCustomContro.xaml
<SomeCustomControl x:Name="someCustomControl">
<Button Command={Binding ElementName=someCustomControl, Path=Reload />
<Button Command={Binding ElementName=someCustomControl, Path=Save />
</SomeCustomControl>

//SomeCustomControl.xaml.cs
.....  //NOT SURE HOW TO ALLOW BINDING TO A ICOMMAND ??

In my SomeCustomControl, I need to support "binding of ICommand in xaml".
I understand DependencyProperties could be bind like this, but in this case I need to bind ICommand.

EDIT
I can use the DataContext SomeView in SomeCustomControl. There is more logic and separation between the two which I can not dissolve. I ‘must’ maintain a reference of Reload/Save ICommands somewhere in my SomeCustomControl.

  • 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-25T23:54:36+00:00Added an answer on May 25, 2026 at 11:54 pm

    Let me get you straight, you want to bind to the Reload and Save right?

    So that needs creating, declaring and defining two dependency properties ReloadCommandProperty and SaveCommandProperty of type ICommand for SomeCustomControl.

    So assuming that SomeCustomControl derives from Control …

    public class SomeCustomControl : Control
    {
        public static DependencyProperty ReloadCommandProperty
            = DependencyProperty.Register(
                "ReloadCommand",
                typeof (ICommand),
                typeof (SomeCustomControl));
    
        public static DependencyProperty SaveCommandProperty
            = DependencyProperty.Register(
                "SaveCommand",
                typeof(ICommand),
                typeof(SomeCustomControl));
    
        public ICommand ReloadCommand
        {
            get
            {
                return (ICommand)GetValue(ReloadCommandProperty);
            }
    
            set
            {
                SetValue(ReloadCommandProperty, value);
            }
        }
    
        public ICommand SaveCommand
        {
            get
            {
                return (ICommand)GetValue(SaveCommandProperty);
            }
    
            set
            {
                SetValue(SaveCommandProperty, value);
            }
        }
    }
    

    After this proper binding to RelodCommand and SaveCommand properties will start working…

         <SomeCustomControl RelodCommand="{Binding ViewModelReloadCommand}"
                            SaveCommand="{Binding ViewModelSaveCommand}" /> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please see the example code below: class A { private: class B { public:
Assuming sr is an IEnumerable<string> , I want to use code like this to
Hej, assuming I have a code that looks like this: List<User> userList = GetUserByName
Assuming that: The C# source code below is compiled under .NET 2.0 (CLR 2.0);
I would like to turn the below jquery code into a function so i
if I have something like below (very basic but I hope you get what
I have some thread-related questions, assuming the following code. Please ignore the possible inefficiency
Assuming A.sql contains the following code, then second Select query won’t be executed due
Assuming I have char C whose ascii code is 0110 0111 . How can
Assuming I have a comments model and a posts model, What code can I

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.