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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:45:24+00:00 2026-06-06T13:45:24+00:00

Application, have a TextBlock and two Buttons, the text is displayed TextBlock by clicking

  • 0

Application, have a TextBlock and two Buttons, the text is displayed TextBlock by clicking on the button (the text of the Q.txt is read line by line, over a hundred lines):

public class QWork
{
   public static int counter = 0;

   public static string GetQ()
    {
        var qFile = new List<string>();

        string pathFile = "Q.txt";
        Uri uri = new Uri(pathFile, UriKind.Relative);
        StreamResourceInfo sri = Application.GetResourceStream(uri);
        using (StreamReader sr = new StreamReader(sri.Stream))
        {
            string line = "";
            while (line != null)
            {
                line = sr.ReadLine();
                if (line != null)
                    qFile.Add(line);  // Add to list
            }
            return qFile[counter];
        }
    }
}

Buttons event handler:

    private void RightButton_Click(object sender, RoutedEventArgs e)//Next text
    {
        qTextBlock.Text = QWork.GetQ();
        QWork.counter++;
    }

    private void LeftButton_Click(object sender, RoutedEventArgs e)//Previous text
    {
        qTextBlock.Text = QWork.GetQ();
        QWork.counter --;
    }

Problem:
When I click LeftButton, a first still shows the following line, but only after previous.
Tell me please, how can I fix it.

Thanks!

  • 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-06T13:45:25+00:00Added an answer on June 6, 2026 at 1:45 pm

    Maybe this can help you

    int counter = 0;
    List<string> qs = null;
    
    private void LoadQs()
    {
        qs = new List<string>();
        qs.Add("aaa");
        qs.Add("bbb");
        qs.Add("ccc");
    }
    
    private string GetQ(bool increase)
    {
        if (increase)
            counter++;
        else
            counter--;
    
        if (counter >= qs.Count)
            counter = 0;
        else if (counter <= 0)
            counter = qs.Count;
    
        string q = qs[counter];
    
        return q;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on WPF application.I have bound my textblock to my button. I
Windows Phone application (Silverlight 3) I have a textblock <TextBlock Text={Binding Key} FontSize=40 Foreground={Binding
I have two collections displayed in my WPF application, and I'd like to have
iHi, in my Windows Phone application in View I have: <TextBlock x:Name=lblink FontSize=15 Margin=30,0,24,0
I have TextBlock in my main form. I set the Text property to different
In my application, I have a TextBlock that I display a Double number in
I have two controls in this example but in the real application i have
In my WPF application I have this: <StackPanel> <TextBlock> <Hyperlink> <TextBlock TextWrapping=Wrap Name=HyperlinkText />
I am developing a WPF application, and have a TextBlock which I want to
I have a TextBlock on my application. I want to update it every second

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.