Starting point

Fixed to work with XAML.
No longer just a dirty port from windows platform. A lot left to be
done.