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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:24:51+00:00 2026-06-07T04:24:51+00:00

I have a fairly complex tree of data which I’m displaying in a WPF

  • 0

I have a fairly complex tree of data which I’m displaying in a WPF UserControl and the control is using DataTemplates to create and link various UI elements up to the various data inside the tree. Here’s a (very) simplistic example which involves a list of items being display in an ItemsControl sitting on a canvas, and each element is represented with a TextBox:

<ItemsControl.ItemTemplate>
    <DataTemplate>
        <TextBox
            Text="{Binding ...}"
            Canvas.Left="{Binding ...}"
            Canvas.Top="{Binding ...}"
        />
    </DataTemplate>
</ItemsControl.ItemTemplate>

Now an event has occurred inside my UserControl whereby I have a reference to one of the list items and I want to set the focus to the TextBox item behind it. Is there an easy way to get the TextBox element from the data object that its Data Context is bound to? Or do I have to manually walk the entire visual tree myself?

I realize I could put a member inside the data element itself and use triggers to do whatever it is I’m trying to do but in my case it would require an extra layer of abstraction that I’d really like to avoid if at all possible.

  • 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-07T04:24:53+00:00Added an answer on June 7, 2026 at 4:24 am

    As you say, if you cannot directly add a member to the item class that you are using, I assume its a built-in type you don’t have access to, you must create a proper View Model to access a trigger like

    <Trigger Property="IsFocused" Value="True">
        <Setter TargetName="myTextBox" Property="FocusManager.FocusedElement" Value="{Binding IsTextBoxFocused}" />
    </Trigger>
    

    It’s another layer of abstraction but you will always find it important to use a View Model that you have access to.

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

Sidebar

Related Questions

I have a fairly complex data model and consequently a fairly complex query (using
Using a stored procedure i have a fairly complex SQL statement which returns a
I have a fairly complex table which is not displaying correctly in IE. For
In my ASP.NET MVC app, I have a fairly complex edit page which combines
I have a web page that I use to update a fairly complex data
I have a fairly complex Core Data database with many entities, attributes and relationships.
I have a fairly complex object which has some C# code written to render
I have a fairly complex user drawn control that is double buffered. Works very
I have a fairly complex ViewModel containing decimal properties, which are exposed to the
I have a fairly complex page which contains an absolutely positioned table (as the

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.