Print Page | Close Window

Markup - jumping to label

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=11055
Printed Date: 15 November 2025 at 6:26am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Markup - jumping to label
Posted By: mnowaczy
Subject: Markup - jumping to label
Date Posted: 16 June 2008 at 9:43am
How to implement jumping to a label when I click on hyperlink (like in HTML)?

I imagine using Tag attribute to search through page but maybe there is en easier way to do it?
Any command to position on destination element (I want it to be visible at the beginning of the screen)?
Page have <ScrollViewer> of course.



Replies:
Posted By: mnowaczy
Date Posted: 18 June 2008 at 6:08am
Any solution to this?


Posted By: Oleg
Date Posted: 18 June 2008 at 6:59am
Hi,
 
 
Here some code to try
 
void CMarkupPadView::OnHyperlinkClick(CXTPMarkupObject* pSender, CXTPMarkupRoutedEventArgs* pArgs)
{
 if (pSender->IsKindOf(MARKUP_TYPE(CXTPMarkupHyperlink)))
 {
  CXTPMarkupScrollViewer* pView = MARKUP_DYNAMICCAST(CXTPMarkupScrollViewer, m_pUIElement->FindName(L"scroll"));
  CXTPMarkupUIElement* pText = MARKUP_DYNAMICCAST(CXTPMarkupUIElement, m_pUIElement->FindName(L"New"));
  if (pView && pText)
  {
   CRect rc = pText->GetMarkupContext()->GetClientBoundingRect(pView);
   CRect rc1 = pText->GetMarkupContext()->GetClientBoundingRect(pText);
   pView->SetScrollPos(SB_VERT, rc1.top - rc.top);
  }
  pArgs->SetHandled();
 }
}
 
and in markup add names "scroll" for ScrollView :
 
 <ScrollViewer x:Name="scroll"  ...


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: mnowaczy
Date Posted: 18 June 2008 at 9:17am
Finding element and setting scroll position works well, but GetClientBoundingRect is private :(

I know my element is visual and scroll start from the beginning of the page so I did like this:

if (pView && pText){
   CXTPMarkupVisual* pVisual = (CXTPMarkupVisual*)pText;
   CRect rc = pVisual->GetBoundRect();
   while (pVisual != 0)
   {
      rc.OffsetRect(pVisual->GetVisualOffset());
      pVisual = pVisual->GetVisualParent();
   }
   pView->SetScrollPos(SB_VERT, rc.top);
}

When I look inside this metod it's not easy to understand it without any help. Hope you'll add Markups classes to Help soon.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net