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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:44:28+00:00 2026-06-12T00:44:28+00:00

I have a textbox and a button in my .xaml. When i click the

  • 0

I have a textbox and a button in my .xaml. When i click the button i am able to open a filedialog and able to select the file as well.

MainWindow.Xaml:

<TextBox Height="93" IsReadOnly="True" Text="{Binding Path=ReadMessage, Mode=TwoWay}" Name="MessageRead" />

<Button Content="Load" Name="I2CLoadBtn" Command={Binding Path = LoadContentCommand />

My ViewModel Class:

public static RelayCommand LoadContentCommand { get; set; }

    private string _ReadMessage;
    public string ReadMessage
    {
        get { return __ReadMessage; }
        set
        {
            __ReadMessage= value;
            NotifyPropertyChanged("ReadMessage");
        }
    }

    private void RegisterCommands()
    {
        LoadContentCommand = new RelayCommand(param => this.ExecuteOpenFileDialog());
    }

    private void ExecuteOpenFileDialog()
    {
        var dialog = new OpenFileDialog { InitialDirectory = _defaultPath };
        dialog.ShowDialog();
        dialog.DefaultExt = ".bin";
        dialog.Filter = "Bin Files (*.bin)|*.bin";           
    }

What i basically want is, once the file is selected, the contents of the file must be saved into the textbox. E.g. If I have a .txt file to be loaded, on loading the contents must get placed inside the textbox.

Please help!!!

  • 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-06-12T00:44:29+00:00Added an answer on June 12, 2026 at 12:44 am

    This is how you get the selected path:

    string path = "";
    if (dialog .ShowDialog() == true)
    {
        path = dialog.FileName;
    }
    
    using (StreamReader sr = new StreamReader(path)) 
    {
         ReadMessage = sr.ReadToEnd()
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a xaml code: <Grid> <WrapPanel> <TextBox ></TextBox> <Button Content=GetIt /> </WrapPanel> </Grid>
I have a form with an input textbox and a button. When I click
I have 2 textBox and 1 button! I want to insert text to one
Lets say we have a textbox and an button. And the user write table
In my code I have one textbox and one button. Whatever place you type
Windows form application(.Net 3.5) I have a textbox and a button on the form.
I have a textbox with an 'Add to clipboard' button next to it. Whenever
This is my problem, I have one textbox, one button and one label. Everything
I have a dropdownlist and a textbox with a button on a form. When
see fiddle i have html table and one textbox and one button.make cell selection

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.