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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:13:25+00:00 2026-05-23T03:13:25+00:00

In my WPF application I have a list of DocumentViewers which are bound to

  • 0

In my WPF application I have a list of DocumentViewers which are bound to some property of an object. I add the object to a ListBox and programmatically apply a datatemplate which binds the property of the object to the DocumentViewer. This means the DocumentViewer isn’t declared at all in the code, but I want to get at it to change a property later on. How can I do this? My code looks like the following:

<DataTemplate x:Key="SomeDataTemplate" x:Name="DocumentViewerTempl">
    <DocumentViewer x:Name="DocV" Document="{Binding DocumentContent}"
                    Style="{StaticResource DocumentViewerStyle1}"/>
</DataTemplate>

The contents of the document are in the DocumentContent property of the Document class, so as you can see, the binding takes place above. My question is how to access the DocumentViewer in the code? I’ve tried giving it a name and referencing that but that’s clearly not the way to do it…

Thanks

  • 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-23T03:13:26+00:00Added an answer on May 23, 2026 at 3:13 am

    You can do this via the ItemContainerGenerator:

    var itemContainer = 
        listBox.ItemContainerGenerator.ContainerFromIndex(index) as ListBoxItem;
    
    // or: 
    var itemContainer = 
        listBox.ItemContainerGenerator.ContainerFromItem(item) as ListBoxItem;
    
    var viewer = 
        itemContainer.ContentTemplate.FindName("DocV", itemContainer) as DocumentViewer;
    
    // Do stuff with viewer
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my WPF application I have a Canvas in which I do some drawing.
I have a small WPF application in which I have a list of files.
I have a WPF application with ListBox that display list of items. Each item
I have an action Edit in my WPF application, which is bound to items
I have a WPF application which presents a list of items. I would like
I have a WPF application that consumes a SharePoint list using Client Object Model.
In the entry form of my wpf application, I have a list of buttons
In my WPF application I have a CheckBox whose IsChecked value is bound to
In my WPF application I have some drawing functionality. I have solved this using
In my WPF application im trying to visualize some temperature data. I have a

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.