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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:03:59+00:00 2026-05-21T10:03:59+00:00

I have an ItemsControl bound to a list of objects. It basically displays a

  • 0

I have an ItemsControl bound to a list of objects.

It basically displays a list of bound properties on screen with a textbox and button next to each one to allow you to add additional information to each database field.

In the onclick of the button I need to take the string in the textbox and store it in the object for that item. The XAML looks a bit like this

            <ItemsControl x:Name="ListDatabaseFields"  ItemsSource="{Binding Path=SelectedImport.ColumnMappings}">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                        <Grid>
                                <StackPanel>
                                    <TextBlock Text="{Binding DatabaseColumn.Name}" TextWrapping="Wrap" Grid.Column="0"/>
                                    <TextBox Name="txtNewFileField" Width="100"/>
                                <Button Name="Add" Content="Add File Field" Style="{StaticResource LinkButton}" Width="50" Click="Add_Click"/>
                                </StackPanel>
                        </Grid>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>

Whats the best way in the XAML to access the ColumnMapping the itemcontrol is bound to for that item and change its file field property.

  • 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-21T10:03:59+00:00Added an answer on May 21, 2026 at 10:03 am

    I’m not sure if i understood your question correctly, please clarify if this is not what you are looking for.


    I have adapted this to my test application, my DataTemplate looks like this:

    <DataTemplate>
        <StackPanel Orientation="Horizontal">
            <TextBlock Text="{Binding Name}"/>
            <TextBox MinWidth="100" Name="tbNewName"/>
            <Button MinWidth="100"
                    Tag="{x:Reference tbNewName}" Click="ButtonNewName_Click"
                    Content="Do Stuff"/>
        </StackPanel>
    </DataTemplate>
    

    Notice the Button.Tag which references the TextBox, i can use it in the handler like this:

    private void ButtonNewName_Click(object sender, RoutedEventArgs e)
    {
        Employee emp = (sender as FrameworkElement).DataContext as Employee;
        TextBox tbNewName = (sender as FrameworkElement).Tag as TextBox;
        emp.Name = tbNewName.Text;
    }
    

    The DataContext is inherited, so the sender (the Button) contains the data-item, in your case a ColumnMapping, the Tag gives me the TextBox and that is all i need for changing a property.

    If you need to reference more controls you could create an array in the Tag.

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

Sidebar

Related Questions

I have an ItemsControl that is bound to a collection of objects. Each object
I have ObservableCollection<Foo> that is bound to an ItemsControl (basically displaying a list). Foo
I have an ItemsControl that is bound to a list of Objects. I have
I have ItemsControl which is bound and creates multiple Polylines, one for each data
I have a ItemsControl bound to a string list. Code:- List<string> possibleAnswers; possibleAnswers =
I want to bind list of objects each of it has UIType (ie textbox,
I have an ItemsControl that is data bound to a list of decimal s.
I have a WPF ItemsControl that is bound to an ObservableCollection. The XAML: <ItemsControl
I have a WPF ItemsControl who's ItemsSource is bound to an observable collection of
I have some XAML <ItemsControl Name=mItemsControl> <ItemsControl.ItemTemplate> <DataTemplate> <TextBox Text={Binding Mode=OneWay} KeyUp=TextBox_KeyUp/> </DataTemplate> </ItemsControl.ItemTemplate>

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.