So the issues are the textBox isn't long enough and the text isn't being centered vertically?
The width should be simple enough. For fixed width fonts like spritefonts it would be len(text)*characterWidth. For normal text objects there is a textWidth expression, but it only gives the width of the previous frame (booo!). You could also do word warping. I think this is handled by the object, but I haven't checked.
Vertical centering is just a matter of moving things up and down. So if you know you have two lines you can leave things as they are, and if you have only one line you can move the line down by half a the height of a letter to center it. You may also be able to utilize the vertical alignment property.
There is an issue if you use lines of dialog with newlines, you'd have to look at the width of each line and use the longest one for the width. Here's it in pseudocode:
var width = 0
var height = 0
repeat tokencount(dialog, newline) times
-- set width to max(width, len(tokenat(dialog, loopindex, newline)*characterWidth)
-- add characterHeight to height
I'll probably stop there, hopefully some of that will help.
Here's an example you can pick apart: