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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:00:19+00:00 2026-05-31T22:00:19+00:00

I want to handle events on a treeview with ACB ( http://marlongrech.wordpress.com/2008/12/04/attachedcommandbehavior-aka-acb/ ). I

  • 0

I want to handle events on a treeview with ACB (http://marlongrech.wordpress.com/2008/12/04/attachedcommandbehavior-aka-acb/).

I am stuck with the bindings in the XAML file. The event is fired but I keep getting null reference exceptions in the ACB library because strategy is null:

    /// <summary>
    /// Executes the strategy
    /// </summary>
    public void Execute()
    {
        strategy.Execute(CommandParameter);
    }

In the XAML file I added the following (excerpt):

xmlns:acb="clr-namespace:AttachedCommandBehavior;assembly=AttachedCommandBehavior"

    <StackPanel x:Name="VerklaringenTreeviewPanel">
    <Border x:Name="TreeviewHeaderBorder" Style="{StaticResource TreeviewBorderHeaderStyle}">
        <TextBlock x:Name="tbTreeviewHeader" Text="Verklaringen concept" Style="{StaticResource TreeviewHeaderStyle}"/>
    </Border>

    <TreeView x:Name="MyTreeview" ItemsSource="{Binding}" Style="{StaticResource TreeviewStyle}">
        <TreeView.Resources>
            <ResourceDictionary Source="..\Themes\TreeviewItemStyle.xaml" />
        </TreeView.Resources>
    </TreeView>

    <StackPanel.Resources>
        <HierarchicalDataTemplate DataType="{x:Type local:MyDataType}" ItemsSource="{Binding MyChildDataType}">
            <StackPanel Orientation="Horizontal" acb:CommandBehavior.Event="MouseDown" acb:CommandBehavior.Command="{Binding SomeCommand}" acb:CommandBehavior.CommandParameter="Hi There">

And in the Viewmodel I added:

        Public Property SomeCommand() As ICommand
        Get
            Return _someCommand
        End Get
        Private Set(value As ICommand)
            _someCommand = value
        End Set
    End Property

    Public Sub New()
        MyBase.New()

        Dim simpleCommand As SimpleCommand = New SimpleCommand()
        simpleCommand.ExecuteDelegate = Sub(x As Object)
                                            Dim test As String
                                            test= "noot" 'I want to hit this breakpoint
                                        End Sub
        Me.SomeCommand = simpleCommand
    End Sub

Who can help me out with the binding?

Regards,

Michel

  • 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-31T22:00:20+00:00Added an answer on May 31, 2026 at 10:00 pm

    The not too descriptive exception is throw because this binding is broken: acb:CommandBehavior.Command="{Binding SomeCommand}".

    So WPF could not find your SomeCommand property. I guess the problem is around the HierarchicalDataTemplate so the DataContextis not what you would expect…

    Check for binding errors in the Visual Studio’s Output window during runtime and you will know what to fix then it should work.

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

Sidebar

Related Questions

So here is my dilemma, I want to handle view events on my view
I want to handle window move events. My first try was to handle DWebBrowserEvents2::WindowSetHeight
I want to use One routine to handle multiple events & i want to
I want to handle events when user pastes some text in TextBox . Which
I'm using knockoutjs to handle different events - one of them is i want
I want to handle the keydown event globally in my application and as such
I have a s:List component. I want to handle a click event to know
I want to handle mouse click in a native MFC application from a C#
I want to handle the focus out Handler only to the component which i
i want to handle the tab keypress in such a way that if there

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.