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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:40:12+00:00 2026-05-23T07:40:12+00:00

I have a UserControl (called Invoice ) with a textbox ( txtReferenceCode ) hosted

  • 0

I have a UserControl (called Invoice) with a textbox (txtReferenceCode) hosted in a TabControl (myTabControl) on MainWindow. From the UserControl I call a window (SearchWindow) which contains a list of stock items. The window needs to return a string value to the textbox contained by the UserControl. I cannot access the textbox on the UserControl from the window and thus cannot pass the string value from the window to the text property.

The UserControl is an instance loaded as a new tabItem (there may be many open as content of tabitems.) I need to only affect the current tabitem instance of the UserControl.

Eg: (Button Click Event in SearchWindow)

Invoice.txtReferenceCode.Text = SearchWindow.txtReferenceCode.Text

I need a simple uncomplicated, solution preferably in VB (but I’ll take C# gladly).

  • 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-23T07:40:12+00:00Added an answer on May 23, 2026 at 7:40 am

    I got it! I am posting the solution here for any who struggle with this issue.

    XAML

    WPF UserControl

    <UserControl x:Class="Invoice"
                 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" 
                 mc:Ignorable="d"
                 d:DesignHeight="300" d:DesignWidth="300">
    
            <TextBox x:Name="txtReferenceCode" Width=100 />
    
    </UserControl>
    

    WPF Window

    <Window x:Class="SearchWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Height="300" Width="300">
    
        <TextBox X:Name="TextToChangeTextBox" Width=100 />
    
    </Window>
    

    Code Behind

    Add a Property to your Window

    Class SearchWindow 
    
         Public ReadOnly Property TextValue
                 Get
                     Return TextToChangeTextBox.Text
                 End Get
         End Property
    
         ...
    
    End Class
    

    now you can use the property in your window to pass a string to the TextBox on the UserControl.

    Public Class Invoice
    
        Private Sub SetValueToTextBox
    
                Dim win As New SearchWindow
                win.ShowDialog()
    
                txtReferenceCode.Text = win.TextValue
    
        End Sub
    
        ...
    
    End Class
    

    *

    And That’s it! EASY!

    *

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

Sidebar

Related Questions

I Have a UserControl called TenantList.ascx which contains a slightly modified GridView from DevExpress
I have usercontrol called as 'DateControl1' in which i have textbox and a calenderextender(ajax).I
I have a UserControl called InputSensitiveTextBox that inherits from TextBox . It has a
I have created a UserControl called AutorControl with a method to clear its textbox:
I have UserControl which contains a TextBox and a Button control. The Button opens
I have defined a textbox with x:Name=txtMyTextBox inside UserControl called MyView. I've noticed that
I'm using ajax in my website to call some information from a UserControl called
I have a usercontrol called MyUserControl.xaml which dynamically adds another user control: UserControl myControl
I have a UserControl called CustomerFinder for searhing customers. And there is "ADD" button
I have a custom UserControl called (for instance) MyPanel, and I want to use

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.