0

I'm working on making a small independent game, and I've reached the point where I'm storing data in XML files, and I'd like to be allow the non-programmers on my team to edit them easily via a GUI, which I'd like to put together with WPF and C#.

I have plenty of experience with C#, but barely any with WPF.

The program would have the following class:

class Foo {
    public string Name;
    public int Age;

    public Foo(string name, int age) {
        Name = name;
        Age = age;
    }
}

And the "database" would just be a

public List<Foo> FooList = new List<Foo>();

What I'd like to make, simplified, is a window with a ListBox on the left side, with "add" and "delete" buttons beneath it (to add and delete items to and from the FooList). The ListBox should have all of the entries in FooList (displaying their Name). On the right side of the window should be a field for Name and Age, and probably some kind of "Save" button.

Now, I could hack this together myself, and I was just about to, when I learned about the existence of data binding. I have no idea how it works (other than that it seems to let you bind controls to variables or something), but it seems like it would make making this a lot easier, right?

I apologize in advance if this seems like too much of a "do everything for me"-type question. I barely know WPF at all, like I said earlier, but I can, for example, handle the serialization and file saving parts myself. I just have no clue how data binding works and how to implement it into my situation (assuming this is even what I want to do).

Thanks in advance!

Adam Rezich
  • 3,122
  • 6
  • 31
  • 39
  • 5
    Have you tried [Google](http://www.google.com/search?q=WPF+data+binding)? – Jonathon Reinhart Jul 03 '12 at 04:25
  • Well, yes, but I was hoping for a quick and direct example of how to use it in a basic scenario like the one I'm trying to make, as Windows forms programming isn't really something I work with on a regular basis. Again, I'm sorry if this is too much of a "do it for me plzkthx" question, I was just looking for some quick guidance. – Adam Rezich Jul 03 '12 at 04:28
  • it does indeed come across as "do everything for me".... there are approximately 8.2 million tutorials on WPF data binding... read a couple and post new questions if any of the specifics don't make sense – Robert Levy Jul 03 '12 at 04:28
  • 1
    I'm only an amateur programmer, and I've used C# to make stuff like IRC bots in the command line, and games with SDL and XNA, so there's no real need for the rudeness. – Adam Rezich Jul 03 '12 at 04:33
  • 1
    @GrayFox374 - if he's building a game, he's probably using XNA or something similar. it's ok to call yourself a .net developer without having created a forms-based UI before :) it's still a lousy question though – Robert Levy Jul 03 '12 at 04:33
  • I did not intend to come across rude, just a little incredulous. – GrayFox374 Jul 03 '12 at 12:39

2 Answers2

2

Here's Microsoft's official WPF databinding tutorial. There's a lot here. And there are many similar tutorials all over the intertubes waiting for you just a google search away. http://msdn.microsoft.com/en-us/library/ms752347.aspx

Robert Levy
  • 28,747
  • 6
  • 62
  • 94
0

Simple answer, use XML Notepad to edit XML. It's lightweight enough for non programmers.

http://www.microsoft.com/en-us/download/details.aspx?id=7973

GrayFox374
  • 1,742
  • 9
  • 13