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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:32:21+00:00 2026-06-13T20:32:21+00:00

In Windows 8, C# + xaml i have some class Class ABC { public

  • 0

In Windows 8, C# + xaml
i have some class

Class ABC
{
 public string a {get; set;}
 public void someMethod()
 {
  **some code, changing a**
 }
}

and binding in xaml

<ListBox x:Name="playlistBox">
     <ListBox.ItemTemplate>
          <DataTemplate>
               <StackPanel Orientation="Horizontal">
                     <TextBlock Text="{Binding a}"/>
                     <Button Name="removeAlbumBtn" Content="method" Click="**NEED BINDING TO SOMEMETHOD HERE**"/>
                </StackPanel>
           </DataTemplate>
      </ListBox.ItemTemplate>
  </ListBox>

So what i must type to call someMethod???

  • 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-13T20:32:22+00:00Added an answer on June 13, 2026 at 8:32 pm

    You need to handle the Click event through a handler method in the code behind of that xaml file. For example, if the xaml you show is in a MyControl.xaml. You’ll have a method like the following in the MyControl.xaml.cs:

    private void removeAlbumBtn_Click(object sender, RoutedEventArgs e)
    {
        var a = ((Button)sender).DataContext as ABC;
    
        if(a != null)
            a.someMethod();
    }
    

    And change the xaml to be:

    <Button Name="removeAlbumBtn" Content="method" Click="removeAlbumBtn_Click"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created blank C#/XAML Windows 8 application. Add simple XAML code: <Page x:Class=Blank.MainPage
I have below XAML code : <Window x:Class=WpfApplication1.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml DataContext={Binding RelativeSource={RelativeSource Self}} WindowStartupLocation=CenterScreen
I have following code public partial class MainWindow : Window { public MainWindow() {
I've wrote the following C# and XAML Code: namespace ListViewExample1 { public partial class
I have the following class: public class Sticky : INotifyPropertyChanged { // ... some
I'm coding a windows form using WPF, XAML, C#. I have a Frame object
I have this XAML: <Window x:Class=WpfBindToCodeBehind.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=Window1 Height=300 Width=300 Loaded=Window_Loaded> <StackPanel Orientation=Vertical>
I have this User Control XAML: <Window x:Class=MyProj.Dialog xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006 xmlns:d=http://schemas.microsoft.com/expression/blend/2008 xmlns:shell=http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell mc:Ignorable=d>
For some reason I can't get this to work at all. I have read
In my Windows Phone 7.1 application, I have some pages made in this way:

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.