-3

I had a problem, and after putting a lot of effort into trying to solve it, I asked a question on Stack Overflow.

However, I was very quickly told that my effort was not enough:

You've done zero research, and made very little effort to explain what you're trying to do. Where in the documentation for ContentControl did you find that it has columns? Why don't you back up and explain what your goal is, in plain English, instead of making up stories about random controls that you know nothing about? That XAML snippet doesn't illustrate your intent. What's "ColumnDataGrid"? People can't read your mind.

Before I asked, I searched the internet for a few days, tried various pieces of code (probably added and deleted 50 plus lines of code, both borrowed from the net and from my own attempts. I re-read a few sections in a few books I have and still could not figure it out. So my last choice was to ask on Stack Overflow and believe me, from a relative beginners perspective , asking on Stack Overflow is the ultimate, certain, definitive and absolute last resort for a way to get an answer.

There is another question that is similar to mine, but it is highly upvoted.

Why is a question, with the same basic premise as mine, upvoted so highly while my question was criticized?

The .NET Framework 3.0 introduced the WPF in 2006, and by the time the other question was asked, the technology was four years old. There should have been some answers out there at that point in time, so why did nobody comment about the lack of research then?

I'm not looking to attract upvotes by asking this question; I just want to learn without being belittled, told to try harder, research more or looked down upon. I'm really hesitant to ask questions here now.

I will post my original content as it has evolved quite a bit. That does not take away the fact that is was immediately commented as not being researched etc.

Question No. 1

Get selected value from combo box in c# wpf

i think this might be a stupid question but I can't find it on the internet.

I have just started using WPF forms instead of WF forms. In a WF form I could just do:

ComboBox.SelectedValue.toString();

and this would work fine.

How do I do this in WPF it doesn't seem to have the option.


My question:

Loop through Content Control in WPF?

How do you loop through DataControls on a WPF form.

In VBA it is as simple as concatenating the control number. eg, looping through a group of textbox controls,

Dim i As Integer 
For i = 1 To 30 
    Controls("txtbox" & i).Value = "" 
Next i

I have 4 DataControl columns I am trying to loop through and I tried something similar with C#, but obviously this does not work.

for (int i = 1; i < 4; i++)
  {
      Column[i].DataContext = sql.Staff_Time_TBLs.Select(item =>
      item.Section_Data).Distinct().ToList();
  }

How would you go about doing this. Do you have to build something like a collection?

Given the first bit of code in VBA, that was what I was trying to do in a C# application. Just like the first question in this post, a sample piece of code was given to display what was trying to be achieved.

I eventually found the answer was this below,

var columns = new List<ContentControl> { Column1, Column2, Column3, Column4 };

I found my mistake was that in my closest try to get do what I was trying to do was due to the fact I was leaving this piece of code out ContentControl

20
  • 8
    One of these is 6 years old and one isn't. Things change. There's a lot more that you can research now that you couldn't when the site was new and had few answers. Jun 9, 2016 at 13:02
  • Also, did you assume that everyone would understand the VBA code which you wrote to explain what you wanted to do in C#?
    – Ajeet Shah
    Jun 9, 2016 at 13:04
  • @RobertLongson, exactly, it has changed to being a lot more hostile.
    – KyloRen
    Jun 9, 2016 at 13:05
  • @Orions, I was hoping someone who knew both VBA an C# to answer . If they didn't move along to the next question in the que. No need for comments like I got.
    – KyloRen
    Jun 9, 2016 at 13:06
  • In that case I think that you should have tagged the question with tag c# too. In general your question should be easy to read and understand the issue which can be easily seen in the first question you mentioned in this post.
    – Ajeet Shah
    Jun 9, 2016 at 13:10
  • In addition to what Robert said, one also looks like the user looked at it in the preview before posting it, and one doesn't.
    – TZHX
    Jun 9, 2016 at 13:10
  • 2
    In 2010 the site was quieter. Today, C# has had >700 questions asked since midnight GMT. That's 56+ an hour, and it's not even the busiest time of the day yet. Also you didn't really include the whole question in this meta post. The whole question is twice as long and half as concise.
    – theB
    Jun 9, 2016 at 13:11
  • @TZHX. I don't know what that means. Sorry.
    – KyloRen
    Jun 9, 2016 at 13:11
  • 4
    I've no idea what you mean by "exactly!". If you asked a question 6 years ago you were likely the first to ask so nobody could point to your lack of research that your question was already answered because it wasn't. Now you're likely the hundredth person to ask an almost identical question so you need to try harder to show why it's different to all the other questions. It should be so much easier to find an answer on this site now than it used to be. Jun 9, 2016 at 13:11
  • 2
    @KyloRen "it has changed to being a lot more hostile" No, the policies and quality standards for on-topic questions have changed since then. Jun 9, 2016 at 13:11
  • @RobertLongson, going off that premise, there should be no more questions to ask until the next version of what ever software you specialize in comes out.
    – KyloRen
    Jun 9, 2016 at 13:13
  • @theB, I didn't include the whole question b/c it was downvoted the way it was first and then I was asked to change it. So I did not want to give a biased opinion. Dammed if you do and dammed if don't around here.
    – KyloRen
    Jun 9, 2016 at 13:15
  • 6
    Are you looking for constructive feedback or just here to troll? Jun 9, 2016 at 13:20
  • 4
    You are taking my responses and making absurd inferences from them, that's trolling. If you don't want to be labelled a troll, don't troll. Jun 9, 2016 at 13:29
  • 1
    @Will, thanks. I am looking at MVVM as we speak, I also have WPF 4.5 Unleashed by Adam Nathan. That is a great book.
    – KyloRen
    Jun 9, 2016 at 22:15

1 Answer 1

5

I've only been a member of Stack Overflow for slightly longer than you have, so I think that I can give some perspective on this.

Your question is only sitting at +1/-2 right now, so I wouldn't stress about the votes too much (it's actually +1 rep for you).

Many very highly up voted questions were written at a time where the site was different. People weren't tired of the same old questions, and a larger variety of things were considered on-topic. Just look at for an example.

Many old questions seem to have snowballed a bit; gathering more and more up votes as people find the page and it helps them solve their problem.

I think one of the main problems we have right now is that there are so many questions that exist already, yet more and more questions are asked each day. Many of these are variations on the same noob questions and it's extremely frustrating to see the site fill up with these questions.

That being said, your question isn't bad. It's just a bit mediocre, but there are plenty of ways to improve.

Include your research

While you may feel that including all your failures is pointless, it helps in a few ways. Besides showing effort, it helps add context. That way, potential answerers will have somewhere to start, and don't end up providing an answer that leads to the same dead ends.

Structure your question properly

The way it reads to me now, the question does not flow, to the point of being confusing. You should start off with a clear problem statement, connect it with some context, then give examples of things that you've tried, maybe with links to where you got the idea from.

Essentially, you should make the job of the answerer as easy as possible.

I'm unfamiliar with the technologies, but here is a basic idea of how I would recommend you write your question:

I'm trying to build insert description here with WPF controls, but I'm running into a problem with iterating over the items.

In VBA, I could use a DataControl, and simply iterate over it with Controls("txtbox" & i).Value = "", but I haven't been able to write something equivalent in C#. So far I've tried code like:

for (int i = 1; i < 4; i++)
{
    Column[i].DataContext = sql.Staff_Time_TBLs.Select(item =>
    item.Section_Data).Distinct().ToList();
}

Of course, this does not work because insert concrete reason here. Is there a way that I can get this code to work or should I try a different approach?

Don't be too concerned about the things people say

It is extremely easy to take things the wrong way. Part of the problem is that you're not very familiar with how things work, but the other part of the problem is that people have unreasonable expectations that you should already know these things.

I think that I too fall into these types of traps because I look over so many questions each day and it's hard to look at things realistically. There's so many low quality, no effort questions out there; on rare occasions where a person doesn't know, but wants to learn, it's very easy to miss and assume the former.

The most important thing to do is to remain calm, as hard as this may be to digest right now. This also applies to here on meta, where voting is stronger and discussion flows more freely. If it makes you feel any better, I've been accused of trolling too. Sometimes, the internet just hampers communication instead of facilitating it, I guess.

While you seem to be failing to convey your message clearly, I feel that some of the comments are getting out of hand. They shouldn't forget that they should still be nice. Let me remind everyone:

Don't expect new users to know all the rules — they don't. And be patient while they learn. If you're here for help, make it as easy as possible for others to help you. Everyone here is volunteering, and no one responds well to demands for help.

1
  • 1
    Thanks for the input. The problem is that I have no formal training in programming, I learn't VBA through books and the net and I can put together an application you would be surprised with, However, that means I do not know all the specialty words that goes with any programming language, so that can limit me sometimes, especially with C#. And I can't go back to school as I have a full time job supporting a family and I code in any spare time I get. I suppose that is what frustrates me, I am trying so hard to learn this myself with all other pressures of life to deal with.
    – KyloRen
    Jun 9, 2016 at 22:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .