The prince has formally accepted an invitation to stay at the palace for part of his visit to the UK this week.