![]() |
Creating MarkupRoutedEvent for Hyperlink in code |
Post Reply ![]() |
Author | |
Andrew666 ![]() Groupie ![]() Joined: 15 October 2008 Status: Offline Points: 27 |
![]() ![]() ![]() ![]() ![]() Posted: 24 June 2011 at 2:54pm |
I'm trying to programmatically create and add a Hyperlink object with a named Click property to a TextBlock using the following pseudo code. It doesn't work and fails when assigning the MarkupRoutedEvent object:
1. Find MarkupTextBlock object using MarkupUIElement.FindName method 2. Clear all the Inlines 3. Create the MarkupHyperlink, MarkupRun and MarkupRoutedEvent objects using MarkupContext.CreateObject 4. Set Run Text property 5. Set MarkupHyperlink Name property 6. Set MarkupRoutedEvent Name property [ fails here ] 7. Assign MarkupRoutedEvent to MarkupHyperlink ClickEvent property 8. Add Run to MarkupHyperlink Inlines 9. Add MarkupHyperlink to MarkupTextBlock Inlines Everything works if I exclude the RoutedEvent steps 6 and 7. Thanks. Regards --Andrew
|
|
![]() |
|
jpbro ![]() Senior Member ![]() ![]() Joined: 12 January 2007 Status: Offline Points: 1355 |
![]() ![]() ![]() ![]() ![]() |
Here's how I create Hyperlinks with a ClickEvent:
Is that helpful? If not, can you post a small sample of what you are trying to do, and I will take a look at it to see if I can understand your problem better through code instead of pseudo-code. |
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
![]() |
|
Andrew666 ![]() Groupie ![]() Joined: 15 October 2008 Status: Offline Points: 27 |
![]() ![]() ![]() ![]() ![]() |
Thanks, that worked a treat. I wasn't using the "AddHandler" method. As usual the controls do what I want - if only I can work out how ;)
--A
|
|
![]() |
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 |