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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:55:51+00:00 2026-05-24T12:55:51+00:00

I have a Listbox as so: xmlns:local=clr-namespace:MyGui.Controls <ListBox Grid.Row=1 ItemsSource={Binding MyData} x:Name=MyDataContainer> <ListBox.ItemTemplate> <DataTemplate>

  • 0

I have a Listbox as so:

xmlns:local="clr-namespace:MyGui.Controls"
<ListBox Grid.Row="1" ItemsSource="{Binding MyData}" x:Name="MyDataContainer">
  <ListBox.ItemTemplate>
    <DataTemplate>
      <local:DataDisplay />
    </DataTemplate>
  </ListBox.ItemTemplate>
</ListBox>

I would like to enumerate through the items from the listbox as objects of type: MyGui.Controls.DataDisplay, as specified in the ItemTemplate. For Example:

foreach (var row in MyDataContainer.Items)
    if (row != null)
    {
        var tmp = MyDataContainer.ItemContainerGenerator.ContainerFromItem(row);
        if (tmp is ListBoxItem)
        {
            return (tmp as ListBoxItem).PROPERTY_I_WANT as DataDisplay;
        }
     }

Is this 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-05-24T12:55:52+00:00Added an answer on May 24, 2026 at 12:55 pm

    This is possible to some degree, most often virtualization will thwart efforts to do this for all items. This being the case it is not recommended, if there is anything you need to access on a control in the ItemTemplate or on the container you should bind it, either in the template itself or the ItemContainerStyle.

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

Sidebar

Related Questions

I have the following constellation in my XAML: <ListBox x:Uid=attributesListBox DataContext={Binding Source={StaticResource EditFeatureWithForeignKeyAttributesViewModel}} ItemsSource={Binding
I have a listbox on a page: <select id=user_list name=user_list size=21 style=width:200px;> <option value=1>User
I have a UserControl which contains a listbox and few buttons. <UserControl x:Class=ItemControls.ListBoxControl xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
I'm binding a ListBox to an ObservableCollection of items which have an Image property,
I have an ListBox UserControl and there is a grid control in the DataTemplate.
I have a user control as follows: <UserControl x:Class=CaseDatabase.Controls.SearchResultControl xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:d=http://schemas.microsoft.com/expression/blend/2008 xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006 mc:Ignorable=d
So I have a ListBox that has a DataTemplate which has a Grid which
I have two ListBox's in a grid. The ListBox ItemsPanelTemplate is set to WrapPanel.
I have a ListBox that displays a list of WPF controls. My problem is
I have a sorted listbox and need to display each item's row number. In

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.