5

Wpf Rant
Seems kinda retarded but it should be trivial to reference a ListBox in a SelectionChanged event doing something like SomeListBox.Items[someIndex] = new TextBox()

in order to replace a simple textblock element with a textbox element that accepts input (replace-in-place), but it's proven to be the most long, aggravating series of unnecessary convoluted bullshit I have encountered so far.

And when I do something like ((ListBox)e.Source).SelectedItem = new TextBox(), nothing break per se but I get no god damn error or feedback, as if it worked, but nothing fucking changed.

I can only assume I'm fucking retarded or like most of the shit coming out of microsoft, WPF is a broken pile of bullshit.

I'd ask on here but every time I ask technical questions I never get any fucking answers. Like a ghost town around here sometimes..

Comments
  • 4
    You are right you are retarded.

    You are changing the selected item to a new textbox but you don't do anything with that textbox. You need to add it to the view first.
  • 1
    @Codex404

    "You are right you are retarded."

    I knew it!

    Thanks Codex!

    I wasn't aware I had to add it to the view, was under the impression it was added during creation.

    Question - Where does my view code 'live'? Where would I add the newly minted textbox? How do I do that in codebehind?
  • 0
    This is what I'm talking about though.

    I'm a complete newb at this. People are always like "ask online" or "find a mentor" and when someone asks they either get no response at all or they get answers that don't mean shit.
  • 0
    @Wisecrack you got a response that points you in the right direction. What else do you want?
  • 0
    @Wisecrack I hope you don't want me to do this?
    https://lmddgtfy.net//...
  • 0
    @Codex404

    I think maybe I wasn't specific enough.

    I'm in the the list's selectionchanged event, according to the ide there is *no* .children.add method on the listbox instance in question.

    If adding it to the list doesn't ADD it then what the fuck is the point of copying it to selecteditem?

    I understand the appeal of xaml but am I expected to write half a fucking page of it every time I want to do something simple like replace a textblock with a textbox ffs?

    I tried an explicit cast to ListBox, and I also tried referencing it by it's name attribute. No luck.
  • 0
    @Wisecrack https://lmddgtfy.net//...

    Now I'm wondering how often I've to post these links until you start researching yourself instead of asking questions and then blaming everyone but yourself for net getting an answer.
  • 2
    If I understand the original question correctly, I believe you need to change the template of the list box item from one that uses a textblock when unselected to one that uses a textbox when selected. Setting the SelectedItem property of the Listbox to a new textbox is not doing what you think it should be doing. Instead, it is a way to set the selected item given a reference to the sheet existing item in the listbox. No different than setting the selectedindex property.
  • 1
    I would also go at this from the XAML end without producing a single line of unnecessary code. Just try costumizing the control's celltemplate, It should suffice.
  • 1
    Random fun fact for WPF :
    If you use very LOW end CPU/GPU (Intel Atom, I’m looking at you) : disable GPU acceleration. Software rendering is faster.
  • 0
    @monkeyboy

    Singly the most helpful comment so far though I

    ended up going with a grid control fwiw.

    Trivially, lists limit cell content to text.
Add Comment