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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:43:09+00:00 2026-05-20T21:43:09+00:00

in my Silverlight 4 application I have a listbox for which I created an

  • 0

in my Silverlight 4 application I have a listbox for which I created an itemtemplate:

    <DataTemplate x:Key="ItemTemplate">
        <Grid Background="{StaticResource BrushCharacteristicListBoxItemBackground}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="10"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <TextBlock x:Name="TextBlockCharacteristicName" Text="{Binding Name}" TextTrimming="WordEllipsis" ToolTipService.ToolTip="{Binding Name}" Margin="6,0,2,0" VerticalAlignment="Center" HorizontalAlignment="Left" />
            <TextBlock x:Name="TextBlockSeperator" Text="=" Grid.Column="1" VerticalAlignment="Center" />
            <Border Grid.Column="2" HorizontalAlignment="Right" Margin="2,2,6,2" Background="{Binding FunctionState, Converter={StaticResource ConvertCharacteristicFunctionState2Color}}">
                <TextBlock x:Name="TextBlockCharacteristicValue" Text="{Binding CalculatedValue, Converter={StaticResource ConvertDouble2Display}}" Padding="2,0" Foreground="{StaticResource BrushCharacteristicListBoxItemBackground}" ToolTipService.ToolTip="{Binding ValueOrFunc}" MaxWidth="72"/>
            </Border>
        </Grid>
    </DataTemplate>     

Now I want to access the Controls defined in the template (i.e. TextBlockCharacteristicName) from the code behind. I need this to manually adapt the size of the Controls, which can’t be done in an other way.

I hooked into the LayoutUpdated event, but did not found a way to access the controls.
I have tried it with

((StackPanel)ListBoxCharacteristics.GetItemsHost()).Children

which gives me a the list of the ListBoxItems, but there seems to be no way to get the controls from there. Can anyway help me out with this problem?

Thanks in advance,
Frank

  • 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-20T21:43:09+00:00Added an answer on May 20, 2026 at 9:43 pm

    Get the small VisualTreeEnumeration chunk of code from this blog: Visual Tree Enumeration.

    Now you can find your “TextBlockCharacteristicName” elements with this code:-

    foreach (var textBlock in ListBoxCharacteristics.Descendents()
        .OfType<TextBlock>()
        .Where(t => t.Name == "TextBlockCharacteristicName") )
    {
        // Do stuff with each Text block.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in my Silverlight 4 application, I have a listbox for which I created a
I have a ListBox in a Silverlight Application. I'm trying to make an editable
I have a silverlight application which reads data from a db and displays them
My silverlight application will have print capability, the printing module is created in separated
I am developing a Silverlight application which has a list <ListBox x:Name=_list_collection SelectionChanged=SelectionChanged ScrollViewer.VerticalScrollBarVisibility=Auto
I have a Silverlight 3 application which calls a traditional .NET Web Service (asmx)
I have silverlight application in asp.net web. In web application i have folder which
I am developing silverlight application. I have a listbox in my application. I am
I have a Silverlight application that has a ListBox of a specific width. I
I have a silverlight application, which requires charts with printing. As silverlight does not

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.