XAML button in ReportControl
Printed From: Codejock Forums
Category: General
Forum Name: XAML Snippets
Forum Description: Post your XAML snippets here for everyone to enjoy :)
URL: http://forum.codejock.com/forum_posts.asp?TID=20596
Printed Date: 30 January 2025 at 4:14pm Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
Topic: XAML button in ReportControl
Posted By: Pidi
Subject: XAML button in ReportControl
Date Posted: 06 February 2013 at 3:46pm
I'd like to use XAML to add a button to my ReportControl.
I tried something like this:
'<StackPanel>' + ;
'<Button Margin="2" Cursor="Hand">' + ;
'<TextBlock HorizontalAlignment="Center">' + sString + '</TextBlock>' + ;
'</Button>' + ;
'</StackPanel>'
|
This works fine, however, it doesn't "function" as a button. When clicked upon, it doesn't press down.
Is it possible what I want?
|
Replies:
Posted By: jpbro
Date Posted: 22 February 2013 at 9:17am
Yes, this is possible. First make sure that you are using the latest version of the ReportControl (15.3.1), as I believe there were bugs in earlier implementations that prevented this from working (although you are free to try with an older version, I may be mistaken).
Next you need to make call the ReportControl.MarkupContext.SetHandler method. The value you pass depends on your language. In VB6, you would call ReportControl1.MarkupContext.SetHandler Me, but other languages will be different (I can't help you if you aren't using VB6).
Next, you need to include the Click event in your button XAML (something like "<Button Click='ClickButton'>ButtonTest</Button>")
Next, you need to create a Public method in your handler object that will accept the button click event from the reportcontrol. In VB6 the declaration would be Public Sub ClickButton(po_Sender As Object, po_Args As Object). Other languages will be different of course.
Then everything should work. Here's a VB6 sample that you can examine and possibly translate to the language of your choice:
Option Explicit
Private Sub Form_Load() With Me.ReportControl1 With .Columns.Add(0, "Test", 100, True) End With .EnableMarkup = True .MarkupContext.SetHandler Me With .Records.Add With .AddItem("") .Caption = "<StackPanel><Button Click='ClickButton' Margin='2' Cursor='Hand'><TextBlock HorizontalAlignment='Center'>Test</TextBlock></Button></StackPanel>" End With End With .Populate End With End Sub
Public Sub ClickButton(po_Sender As Object, po_Args As Object) MsgBox "Button Clicked!" End Sub
|
NOTE: This sub-forum is typically used for XAML snippets - e.g. samples, ideas, experiments, etc... If you post to the ReportControl forum (ActiveX or MFC depending on your library type), you will likely see a quicker response to your questions.
------------- Product: Xtreme SuitePro (ActiveX) version 16.2.6 Platform: Windows XP - SP3
Language: Visual Basic 6.0 SP6
|
|