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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:57:58+00:00 2026-06-15T08:57:58+00:00

I am new to WPF, and trying to develop a small application using DataBinding

  • 0

I am new to WPF, and trying to develop a small application using DataBinding following the MVVM paradigm.

I am trying to provide a binding functionality to the ObservableCollection of Documents (my type). The First Label would display a Documents path (available through Attribute property), while the next children – Pages of the Documents – would display appropriate information: page index and page content (an image).

Here is an issue – how can I create a lookup binding to a parent Label? On Button Click command I would like to pass the documents path, which was available earlier in the first DataTemplate.

Is there a way to tackle this issue?
How would you recommend going around it?

Also, is there a better way to tackle “nested” structures (collections within collections)?

Here is the code https://gist.github.com/b5760982ba81e8ee4036, line 14

  • 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-15T08:57:59+00:00Added an answer on June 15, 2026 at 8:57 am

    you should use RelativeSource:

    <ItemsControl ItemsSource="{Binding Documents}">
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <StackPanel>
                <Label Content="{Binding Path=Attribute.Path}"/>
                    <ItemsControl ItemsSource="{Binding Pages}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <StackPanel>
    
    
    
    
    <Label Content="{Binding Index}"/>
                                    <Button Content="{Binding Content}"
                                            Command="{x:Static viewModel:DocViewModel.Tests }" 
                                            CommandParameter="{Binding Path=DataContext.Attribute.Path,RelativeSource={RelativeSource AncestorType=ContentPresenter, Mode=FindAncestor,AncestorLevel=2"/> 
                                </StackPanel>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </StackPanel>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    

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

Sidebar

Related Questions

I'm new to WPF development with C#, and I'm trying to develop an application
I'm new to WPF and MVVM, but I'm trying to create an application-level viewmodel
I'm very much new in WPF & MVVM paradigm and i'm trying hard to
I am new to WPF. I'm trying to build an application which has a
I am new to WPF data binding / style / templates... I am trying
I'm new to WPF and trying to figure out all this databinding stuff. When
I'm trying to get a legacy MFC application and a new WPF usercontrol to
I'm trying to integrate a new WPF control into an existing WinForms application and
I'm working on a new WPF application and I'm trying to stay as close
I'm new to WPF and I'm trying to figure out how data binding works,

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.