The code in this thread is for XF1 but XF2 has a very similar JavaScript framework and so you can achieve a similar thing in a similar way.
HTML:
<xf:textboxrow name="something" data-xf-init="auto-complete" data-single="1" data-acurl="{{ link('your/auto-complete-url') }}" />
You then need to add code reachable at the above
data-acurl (whatever URL it might be) similar to the code you'll see at
XF\Pub\Controller\Member::actionFind which is where the default user auto-complete code happens.
You'll also likely need a view class and
renderJson method similar to
XF\Pub\View\Member\Find::renderJson to format the results found by the controller.
Hope that helps but if not then please post a new thread with more details about what you're trying to do.