2
inaba
5y

God damn it wpf I just wanna bind an ObservableCollection<string> to an itembox and then have textfields inside that item box that modifies those strings and have the modifications stay there https://imgur.com/a/Un2nk9V !

Comments
  • 0
    Because I'm a newbie to wpf I'd love to know if you solve the problem or worked around it. Learning as I go. Are you new too?
  • 0
    I was just looking at the docs for ObservableCollection and apparently it only refreshes when an item is added or removed from the list in question, but NOT when a change occurs so you might have to bind an event to the textboxes to detect when they are changed and then do a manual refresh.

    But thats just my best guess. I've only been using c# for a week.
  • 0
    @Wisecrack according to reddit I'm "supposed" to make a wrapper class containing the string that inherits from inotifypropertychanged and then having the observablecollection contain those wrapper classes. Either way it's not gonna be pretty
  • 0
    @inaba

    Try using a collection style in xaml instead, in order to bind the relevant event to do the refresh for you.

    I try to avoid creating classes as much as possible simply because it's one more thing to keep track of in my headspace.
  • 1
    @Wisecrack well shit, looks like making a wrapper class worked.

    https://github.com/inabahare/...

    with the added bonus that I rediscovered "implicit operator" which is really nice
  • 1
    @inaba

    Really cool, wasn't aware of implicit operators. Saves me having to do all these fucking casts all over the fucking place.
  • 1
    @Wisecrack yeah implicit operators is one of those things that makes C# such a nice language to use. Properties as well
Add Comment