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

  • Home
  • SEARCH
  • 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 3318606
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:43:33+00:00 2026-05-17T22:43:33+00:00

I need to bind a textblock.text property to a single element in an observable

  • 0

I need to bind a textblock.text property to a single element in an observable collection, or array element, and have the text update using the INotifyPropertyChanged or INotifyCollectionChanged, whichever is best.

Most examples describe ways to bind listboxes or other list views to entire collections, but my application needs to update several textblocks on a screen depending on notification of a change in one or more elements of an array.

textblock1.Text = MyArray(0)...
textblock2.Text = MyArray(1)...
textblock3.Text = MyArray(2)...
textblock4.Text = MyArray(3)...
etc...

Is it possible to bind a single textblock to a single array element?

Is it possible to get notification of the proper type that will update one or more of the textblocks if any assigned element changes?

  • 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-17T22:43:33+00:00Added an answer on May 17, 2026 at 10:43 pm

    All things are possible in WPF, one way or the other (or, usually, both, plus a bunch more).

    The easy part first – if you’ve properly implemented INotifyPropertyChanged on the object in your array, bindings should update properly. INotifyCollectionChanged notifies you if elements in a collection have changed (i.e. been added/deleted).

    It sounds like you are trying to update an unknown number (or even a known number, it doesn’t really matter) of TextBlocks. Likely, the best way to do that is to use some kind of ItemsControl (ListBox is one) with an ItemsTemplate, and optionally the ItemsPanel. This will be the easiest way to maintain, in case the definition of the collection changes.

    For instance, here is one ItemsControl example.

    <ItemsControl x:Name="itemsExample"
                  ItemsSource="{Binding MyCollection}">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel HorizontalAlignment="Stretch" IsItemsHost="True" />
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding SomeStringProperty}" Grid.Column="0" />
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
    

    If, however, you really do want to bind individual TextBlocks, one way you can do it by implementing IValueConverter. You would then bind each of your TextBlocks to the collection, and use a ConverterParameter with the appropriate index. The converter would then just return the value of a string at that index.

    <TextBlock Text="{Binding MyCollection,
                              Converter={StaticResource myObjectConverter},
                              ConverterParameter=0}" />
    

    If you are using MVVM, another possibility is to have properties for each of the elements of your array, and bind to those properties. However, if you are doing that, I would question the need for the array in the first place.

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

Sidebar

Related Questions

I'm trying to bind a TextBlock's Text property in a very dynamic way. I
I need to bind the column Header text of a DataGrid to a Resource
I need TextBlock.Text to be retrieved from translation manager, something like <TextBlock Text={Binding TranslateManager.Translate('word')}
I need to bind labels or items in a toolstrip to variables in Design
I need to bind a method into a function-callback, except this snippet is not
I need a way to bind POJO objects to an external entity, that could
need ask you about some help. I have web app running in Net 2.0.
I have a wpf control named DataPicker which has a dependency property named SelectedDate.
Need a function that takes a character as a parameter and returns true if
Need a way to allow sorting except for last item with in a list.

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.