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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:04:17+00:00 2026-05-26T02:04:17+00:00

I have a need in a DataTemplate to have my binding going to potentially

  • 0

I have a need in a DataTemplate to have my binding going to potentially 2 different types of RelativeSource ie something like this:

AllowDrop={Binding RelativeSource={RelativeSource AncestorType={x:Type Label} or AncestorType={x:Type TextBox}}, Path=AllowDrop}

In this case the relativeSource will look up the tree and find the first ancestor of type Label or TextBlock. Now I know what you’re all going to say, “Why the heck to you want to do something stupid like that for??” Fair question, I’m glad you asked 🙂 The reason is that I am using the WPFish grid from syncfusion. I say WPFish because whoever wrote it didn’t have a clear understanding of how WPF should work and it requires quite a few hacks to get it to work as it should. One of the hacks I need to set AllowDrop of a ContentControl in my template to be the same as the AllowDrop property on their grid. Normally this would be a fairly simple matter of just binding with a RelativeSource type of their grid, but they have 2 grids. One is called GridControl and the other GridDataControl. So I need to search up the tree to find the first control of type GridControl or GridDataControl and grab the AllowDrop property from that.

Thanks in advance,
Michael

  • 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-26T02:04:18+00:00Added an answer on May 26, 2026 at 2:04 am

    Use a Binding Converter and bind to the element itself and then walk the visual tree in the binding converter to find the element you want…..uuugggglllyyy!!

    {Binding Path=., RelativeSource={RelativeSource Self}, Converter={StaticResource findTheCorrectParentConverter}}

    and some code in your converter like so:

    DependencyObject parent = VisualTreeHelper.GetParent(item);
    while(!(parent is TextBox|| parent is Label)){
       parent = VisualTreeHelper.GetParent(parent);
    }
    
    if (parent != null){
       //do some stuff with your stuff.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have columns defined like this: <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBox Text={Binding Path=COLUMN_NAME, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}
I have something like this: <ListBox ItemsSource={Binding List}> <ListBox.ItemContainerStyle> <Style TargetType=ListBoxItem> <Setter Property=HorizontalContentAlignment Value=Stretch></Setter>
I have need to pack four signed bytes into 32-bit integral type. this is
I have a gridview were I define some columns, like this... <GridViewColumn.CellTemplate> <DataTemplate> <TextBlock
I need to create a TreeView in WPF that looks something like this: Admins
I have this listbox : <ListBox x:Name=MyList ItemsSource={Binding ListOfBullets, Mode=TwoWay, Converter=StaticResourcedebugConverter}}> <ListBox.ItemTemplate> <DataTemplate> <local:TaskStepControl
i have this LongListSelector bound to observerableCollection <DataTemplate x:Key=ucItems > <Grid Margin=0,0,0,17> <TextBlock Text={Binding
I have a WPF application where I need to do something like that :
I have a need to build the data string dynamically. This is not working,
I have a need for two slightly different classes, that have the same members,

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.