Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The default link text is Go There but it can be customised by providing your own XAML message string with your link text surrounded by the <a></a> tags when inserting the element. To use a custom XAML message you need to set the flag NI_FLAG_MESSAGEBAR_USERXAML CUSTOMMESSAGE in the NAVSETITEM structure. strLabel then becomes the custom XAML and the Hyperlink node's Tag attribute in the XAML specifies the location to navigate to. e.g. 

Code Block
void AddMessageBarItem(LPCWSTR text, LPCWSTR link)
{
	// First get the root of the MESSAGEBAR domain
	NAVSETITEM messageBarRootData;
	memset(&messageBarRootData, 0, sizeof(NAVSETITEM));
	if( !NavGetItem(_T("MESSAGEBAR"), &messageBarRootData) )
	{
		return;														// Failed to find MESSAGEBAR root
	}
	NavHandle messageBarRoot = messageBarRootData.hItem;
 
	NAVSETITEM newItem;
	memset(&newItem, 0, sizeof(newItem));
	newItem.flags = NI_FLAG_MESSAGEBAR_USERXAMLCUSTOM_MESSAGE;
	newItem.EventMask = NI_EVENT_MOUSE_LCLICK;

	std::wstring strLabel;
	FormatString(strLabel,newItem.strLabel = L"<Image Source='2400'/><TextBlock Padding='3, 0, 20, 0' VerticalAlignment='Center'>This This is the message:text <Hyperlink Tag='MESSAGEBAR\\MyComponent'>%s</Hyperlink></TextBlock>", CResString(IDS_LABEL_THEREISANOTIFICATION).GetBuffer(0), CResString(IDS_LABEL_GOTONOTIFICATIONS).GetBuffer(0));

	ItemNew.strLabel = strLabel.c_str();
	ItemNew.strDescription<a>with an embedded link</a> to navigate to";
	newItem.strDestination = _T("{Notifications}");	   // where to go to
	ItemNewnewItem.lParam = (LPARAM)this;
	ItemNewnewItem.pInterface = &gTaskInterface;
	NavInsertItem(hMessageBar, _T("NotificationWarning"), &ItemNewnewItem);
	hWarningNavHandle messageBarItem = ItemNewnewItem.hItem;
}

Hyperlink tag is always the item to look up to check how the event is processed (NOTIFY or GOTO).

...