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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:13:02+00:00 2026-05-30T15:13:02+00:00

How can I bind event handler to the custom object that i created? here

  • 0

How can I bind event handler to the custom object that i created?

here is my XAML

 <ListBox x:Name="ListData">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Margin="0,0,0,30">
                                    <Image VerticalAlignment="Top" HorizontalAlignment="Left" Source="{Binding Path=TileImage}" Width="175" Height="175" />
                                    <TextBlock  Margin="5" Width="200" TextWrapping="Wrap" VerticalAlignment="Top" HorizontalAlignment="Left" Text="{Binding Path=TileName}" FontSize="25"/>
                                </StackPanel>
                            </DataTemplate>            
                        </ListBox.ItemTemplate>
                    </ListBox>

Code Behind

    // Create collection
    ImageTiles = new ObservableCollection<ImageTile>();

    // Create each object in the collection
    ImageTile RSS= new ImageTile("RSS", "/Images/Hard.jpg");
    ImageTile test= new ImageTile("test", "/Images/Hard.jpg");
    ImageTile Exam= new ImageTile("Exam", "/Images/Hard.jpg");
    ImageTile Settings = new ImageTile("Settings", "/Images/Hard.jpg");

    ImageTiles.Add(RSS);
    ImageTiles.Add(test);
    ImageTiles.Add(Exam);
    ImageTiles.Add(Settings);

    this.ListData.ItemsSource = ImageTiles;

I would like to bind the event handler along with each ImageTile. Any idea how to do so? =)

  • 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-30T15:13:03+00:00Added an answer on May 30, 2026 at 3:13 pm

    Based on your code structure I’ll answer assuming you’re not using MVVM or the like, however I’d definitely recommend that pattern for Silverlight development.

    Nevertheless, your datasource binding would be something like:

    <ListBox x:Name="ListData" ItemsSource="{Binding ImageTiles}">
    
    </ListBox>
    

    You could create a single generic click handler in your code behind and assign the Image’s click event to that handler.

    <ImageButton VerticalAlignment="Top" HorizontalAlignment="Left" Source="{Binding Path=TileImage}" Width="175" Height="175" Click="imageButton_Click" />
    

    You could then have a method on your object responsible for redirecting to whatever necessary place for that particular image tile. Then in your code behind handler would resemble this:

    private void imageButton_Click(object sender, RoutedEventArgs e)
    {
        var imageTile = ((ImageButton)sender).DataContext as ImageTile;
        imageTile.RedirectSomewhere();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

With jQuery you can bind functions to an event triggered on a DOM object
I've done some experimenting, but can't seem to successfully bind one event handler to
How can bind an event on a WPF Control to a method on my
I can bind a jquery event to this element like: <script type=text/javascript> $('#new_key').ready(function() {
For some reason my bind events won't work. You can see my code here:
I have a user control where the XAML of the control can bind to
I've an ASP.Net 2.0 Gridview control that I can bind a List<T> too, for
How can one pass multiple arguments along with an event object to an event
I'm working on custom control that I can use for interactions within my app
How do I create an event on my custom asp.net control which can bubble

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.