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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:27:14+00:00 2026-06-06T23:27:14+00:00

I have a 3rd party SplitButton control that exposes some DropDownContent and a boolean

  • 0

I have a 3rd party SplitButton control that exposes some DropDownContent and a boolean IsOpen dp to control whether the drop down content is shown or not.

In the case the DropDownContent is a StackPanel with several Buttons, each of which is bound to a command in the view model. In addition to executing that command, clicking the button needs to close the open DropDown content, which I am doing with the AttachedBehavior below.

But my binding, which simple needs to get a reference to the ancestor SplitButton control doesn’t work. In the binding, you will note I am trying to Find the first Ancestor control of type SplitButton. I do see however that the debug info says ancestor level 1, so I changed the level to as high as 4, but still with an error.

Can someone see what the fix is?

binding error

System.Windows.Data Error: 4 : Cannot find source for binding with reference
‘RelativeSource FindAncestor, AncestorType=’Xceed.Wpf.Toolkit.SplitButton’,
AncestorLevel=’1”. BindingExpression:(no path); DataItem=null; target element is
‘CloseDropDownContentBehavior’ (HashCode=8896066); target property is ‘DropDownButtonElement’ (type ‘SplitButton’)

xaml

<DataTemplate x:Key="AddNewPartyTemplate">
    <StackPanel HorizontalAlignment="Right" Margin="10">

        <toolkit:SplitButton x:Name="theSplitButton" Content="{resx:Resx Subject_AddNewWithChoices}">
            <toolkit:SplitButton.DropDownContent>
                <StackPanel x:Name="theStackPanel">
                    <Button Content="{resx:Resx Person}" Command="{Binding AddNewPersonCommand}" 
                        >
                        <i:Interaction.Behaviors>
                            <local:CloseDropDownContentBehavior 
                  ***              DropDownButtonElement="{Binding 
                                    RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type toolkit:SplitButton}}}"/>
                        </i:Interaction.Behaviors>
                    </Button>
                    ...

                </StackPanel>
            </toolkit:SplitButton.DropDownContent>
        </toolkit:SplitButton>
    </StackPanel>
</DataTemplate>

attached behavior

public class CloseDropDownContentBehavior : Behavior<ButtonBase>
{
    private ButtonBase _button;

    protected override void OnAttached()
    {
        _button = AssociatedObject;
        _button.Click += OnPartyButtonClick;
    }

    protected override void OnDetaching()
    {
        _button.Click -= OnPartyButtonClick;
    }

    // **** the point of it all
    void OnPartyButtonClick(object sender, RoutedEventArgs e) { DropDownButtonElement.IsOpen = false; }

    public static readonly DependencyProperty DropDownButtonElementProperty =
        DependencyProperty.Register("DropDownButtonElement",
        typeof(SplitButton), typeof(CloseDropDownContentBehavior), new UIPropertyMetadata(null, OnDropDownElementChanged));

    public DropDownButton DropDownButtonElement
    {
        get { return (DropDownButton)GetValue(DropDownButtonElementProperty); }
        set { SetValue(DropDownButtonElementProperty, value); }
    }

    private static void OnDropDownElementChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {

    }
}
  • 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-06T23:27:17+00:00Added an answer on June 6, 2026 at 11:27 pm

    Guessing it’s because Interaction.Behaviors isn’t part of the visual tree, so the binding won’t find the ancestor. Have you tried simply:

    DropDownElement="{Binding ElementName=theSplitButton}"
    

    Update from comments: the solution in this case is to simply use x:Reference:

    DropDownElement="{x:Reference theSplitButton}"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a 3rd party control that is quite complex and takes some time
We have a 3rd party program that appears to have some sort of an
I have some 3rd party Flash SWFs on my site that are up to
I have some 3rd party jar files that I want to reference in my
so I have some 3rd party native library that works only in 32 bit
I'm in a difficult position: We have a 3rd party enterprise system that exposes
I have a 3rd party control that allows for signature capture. I am capturing
I have a 3rd party server side control that generates JavaScript and I'd like
Let's say you have some 3rd-party library class that you want to extend, simply
I have a 3rd Party tool that generates an xml spreadsheet (*.xls). I have

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.