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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:02:04+00:00 2026-05-24T10:02:04+00:00

I am trying to create a datapager usercontrol. This user control has one event

  • 0

I am trying to create a datapager usercontrol. This user control has one event declared in its code behind :

public event EventHandler OnPageIndexPagerChanged;

I use this control in a main usercontrol, and I bind my event to another event in the code behind like this :

xaml :

OnPageIndexPagerChanged="SuperDataPager_OnPageIndexPagerChanged"

c# (Code behind) :

private void SuperDataPager_OnPageIndexPagerChanged(object sender, EventArgs e)
        {
            var viewModel = DataContext as ViewSchedeConsuntiviViewModel;

            if (viewModel != null)
            {
                viewModel.FilterCommand.Execute(sender);
            }
        }

And this works fine, But I would have liked to skip passing through the code behind an do something like :

OnPageIndexPagerChanged="{Binding Path=FilterCommand}"

This, I already do for the filter button, present in my main usercontrol, therefore I thought I could do the same for this event. But every time I receive an error :


Impossibile assegnare alla proprietà
‘Super.Silverlight.SuperDataPager.OnPageIndexPagerChanged’. [Line: 90
Position: 55]


‘iexplore.exe’ (Silverlight): Loaded ‘C:\Program Files (x86)\Microsoft
Silverlight\4.0.60531.0\it\mscorlib.resources.dll’ su
System.Windows.Application.LoadComponent(Object component, Uri
resourceLocator) su
Super.Silverlight.SchedeConsuntivi.InitializeComponent() su
Super.Silverlight.SchedeConsuntivi..ctor()

Sorry for the error in Italian, but I was unable to get the exact translation -> (unable to assign property…)

Could someone explain me this behavior?

Thanks for reading,

[EDIT]
Here is the my view Model for the main usercontrol :

 public class MyViewModel : DependencyObject, INotifyPropertyChanged
{
      public ICommand FilterCommand { get; set; }

      public MyViewModel()
      {
         FilterCommand = new Super.Silverlight.Tools.DelegateCommand<object>(p => Filter());
      }

    public void Filter()
    {
        //....blah blah blah...
    }
}

[/EDIT]

  • 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-24T10:02:05+00:00Added an answer on May 24, 2026 at 10:02 am

    First of all your Event is not a RoutedEvent, something you should consider. But thats not the main problem.

    Of course you can’t set an ICommand to an EventHandler. Don’t get confused of RoutedEvents with RoutedCommands. You have 2 options, you can give your UserControl an dependency Property of type ICommand and just fire that inside your code behind. In XAML you can bind now your command. Or if you want to have that as an event, again consider using RoutedEvents, there are options to bind commands to routedevents like EventBehaviorFactory and some more.

    The easiest solution would be to use an ICommand directly in you user control and remove the event.

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

Sidebar

Related Questions

I'm trying create a log specifically for logging user account activity. I created this
I'm trying create simple application in C++. This application has to read from file
Trying to create a user account in a test. But getting a Object reference
I am trying create a small web application that allows a user to login
Trying to create the following routine in MySQL Workbench yields a This object's DDL
I'm trying create this function such that if any key besides any of the
I am trying create a table and add this table into tablecell (table inside
I am trying create a prototype where one of the features is a dropdown
I'm trying create a small http proxy service. This is not working so well.
I am trying create alert dailog using glade,but its not working .am i doing

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.