https://github.com/tekkub/wow-ui-sou...ainerFrame.xml
https://github.com/tekkub/wow-ui-sou...ainerFrame.lua
As d87 pointed out, these ARE exactly where you should start STUDYING. This is how Blizzard themselves make the bags. ALL the functions in the lua will be needed to simply maintain the existing features. The .xml will also be needed unless you plan to convert it all manually into .lua code.