SOLVED: MarkupContext.SetHandler method in VB.net |
Post Reply |
Author | |
gibrael
Groupie Joined: 17 March 2009 Status: Offline Points: 18 |
Post Options
Thanks(0)
Posted: 19 April 2012 at 6:31am |
Hi,
How would we use the Sethandler method in VB.net? In VB6, it's simply Dim markup as MarkupLabel markup.MarkupContext.SetHandler Me How do we do this in .NET? It's always throwing an InvalidCastException. Thanks.
|
|
--
Codejock Xtreme Suite Pro 15.2 VisualStudio 2010 Windows 7 |
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
I don't have a VB.Net sample handy, but here is some C# code. I assume you are wanting SetHandler to use events in Markup: /* Your class needs to implement the IDispatch interface. You need to add "using System.Runtime.InteropServices;" at the top of your file and "[ComVisible(true), ClassInterface(ClassInterfaceType.
AutoDispatch)]" above your class declaration. Please note that you need to set the event handler in Markup, i.e. <Hyperlink Click='Hyperlink_Click'> */ //Need to include this using System.Runtime.InteropServices; namespace MarkupSample { public Form1() { InitializeComponent(); } //Need this line [ComVisible(true), ClassInterface(ClassInterfaceType.AutoDispatch)] public partial class Form1 : Form { Label1.Caption = "<TextBlock>Click <Hyperlink Tag='This!' Click='Hyperlink_Click'>this</Hyperlink> or <Hyperlink Tag='That!' Click='Hyperlink_Click'>that</Hyperlink> link. (Shows how to handle Markup Events)</TextBlock>"; Label1.MarkupContext.SetHandler(this); } //Then need this [ComVisible(true)] public void Hyperlink_Click(XtremeMarkup.MarkupObject Sender, XtremeMarkup.MarkupRoutedEventArgs Args) { try { XtremeMarkup.MarkupHyperlink Element; Element = (XtremeMarkup.MarkupHyperlink)Sender; MessageBox.Show("Clicked: " + Element.Tag); } catch { MessageBox.Show("Clicked"); } } }
|
|
gibrael
Groupie Joined: 17 March 2009 Status: Offline Points: 18 |
Post Options
Thanks(0)
|
Wow!
Thanks a lot! I've been wracking my brains whole afternoon looking for a solution! This worked perfectly! Thanks again!
|
|
--
Codejock Xtreme Suite Pro 15.2 VisualStudio 2010 Windows 7 |
|
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 |