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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:49:48+00:00 2026-05-28T05:49:48+00:00

I have a second window which opens when a certain staffname is searched for,

  • 0

I have a second window which opens when a certain staffname is searched for, this window prompts you to choose between the 2 staff members with the same name. The window then needs to return a value to the parent window to populate a datatemplate with relating data from the xml file.

I’ve tried to create a string which will be updated with a value depending on which button is clicked, this string can then be returned to the calling method on the first window and populate binding data in the Linq to Xml query.

But when it runs it causes a stackoverflow exception and that it could be an infinite loop. I’m not sure enough about c# to know what to change.

public partial class Choice : Window
{
    private string StaffChoice;

    public Choice()
    {                      
        InitializeComponent();
    }
    public string staffChoice
    {
        get { return this.StaffChoice; }
        set { staffChoice = StaffChoice; }
    }

    private void btnMRG_Click(object sender, RoutedEventArgs e)
    {
        StaffChoice = "MRG";
        this.Close();
    }

    private void btnRPG_Click(object sender, RoutedEventArgs e)
    {
        StaffChoice = "RPG";
        this.Close();
    }
}

Any help or suggestions would be great!

Thanks in advance!

  • 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-28T05:49:49+00:00Added an answer on May 28, 2026 at 5:49 am

    Firstly, your naming conventions are wrong – the field should be called staffChoice and the property should be called StaffChoice. Please read the .NET naming conventions for more information. However, now look at your property closely:

    public string staffChoice
    {
        get { return this.StaffChoice; }
        set { staffChoice = StaffChoice; }
    }
    

    What do you think the setter does? There are two problems with it:

    • It ignores the value that you’re trying to set it to.
    • It calls itself recursively.

    You could fix this by keeping the manually-declared field, fixing the naming conventions, and changing the property to set the variable to value like this:

    private string staffChoice;
    
    public string StaffChoice
    {
        get { return staffChoice; }
        set { staffChoice = value; }
    }
    

    However, it would be simpler to use an automatically implemented property:

    public string StaffChoice { get; set; }
    

    This will create the backing field and the getter/setter for you automatically.

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

Sidebar

Related Questions

I have a page on which is a link. This link opens a second
I have a JavaScript application which opens an ExtJS Window, containing an ExtJS TabPanel,
I need to open a second browser window or tab, but it must have
I have this in my class When the second function is called php errors
I have an app which when opened, displays a splash/loading screen. I had this
I have a thread that opens a form of type MyMessageAlert. This form is
I have a C program which opens a handle to a COM port, writes
We have an application that produces HTML documents which the user opens in word
Say, for instance, you have a popup which opens from your main page. The
we want to have the second biggest element. We first use ANY to exclude

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.