![]() |
Markup - jumping to label |
Post Reply
|
| Author | |
mnowaczy
Groupie
Joined: 16 June 2008 Status: Offline Points: 12 |
Post Options
Thanks(0)
Quote Reply
Topic: Markup - jumping to labelPosted: 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. |
|
![]() |
|
mnowaczy
Groupie
Joined: 16 June 2008 Status: Offline Points: 12 |
Post Options
Thanks(0)
Quote Reply
Posted: 18 June 2008 at 6:08am |
|
Any solution to this?
|
|
![]() |
|
Oleg
Senior Member
Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
Quote Reply
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 |
|
![]() |
|
mnowaczy
Groupie
Joined: 16 June 2008 Status: Offline Points: 12 |
Post Options
Thanks(0)
Quote Reply
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. |
|
![]() |
|
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |