ThisForm class methods

FindElement method

This method finds a control by its name and returns a reference to that control on a form as a FrameworkElement type.

Syntax

public static FrameworkElement FindElement(string elementName)

Parameters

elementName

Type:  System.String

The name of the control to find.

Return Value

Type:  System.Windows.FrameworkElement

Example

This example finds a combo box on the form and enables it.

ComboBox cbx = ThisForm.FindElement("Cbx_MailingAddress") as ComboBox;
cbx.IsEnabled = true;

FindElement<T> method

This method finds a control by its name and returns a reference to that control on a form as a T type.

Syntax

public static T FindElement<T>(string elementName)

Type Parameters

T

The type of control to be found and returned.

Parameters

elementName

Type:  System.String

The name of the control to find.

Return Value

Type: T

A reference to an instance of a control of type T or null if no control is found or control with elementName is of different type then T.

 

Example

ComboBox cbox = ThisForm.FindElement<ComboBox>("Cbx_MailingAddress");
if (cbox != null)
	Cbox.IsEnabled = true;

GetFormMetadataValue method

This method provides a way to extract metadata values from a form.

Syntax

public static string GetFormMetadataValue(string key)

Parameters

key

Type: System.String

The name of metadata value to extract.

Return Value

Type: System.String

The string value of metadata record or null if no record with the given key is not found.

 

 

GetLocalizedString method

This method is to be used to get a string from the current localization resource.

Syntax

public static string GetLocalizedString(string stringName)

Parameters

stringName

Type: System.String

The name of a string to get from the current localization resource. The name can but doesn’t have to start with the ‘$’ character.

Return Value

Type: System.String

The localized string or null if no string with the given name is found.

 

PrintAll method

Call this method to print the current form.

Syntax

public static void PrintAll()

RegisterValidationRole method

Use this method to register validation for the selected control.

Syntax

public static void RegisterValidationRole(
FrameworkElement element, 
LocalizableValidationRole role
)


Parameters

element

Type: System.Windows.FrameworkElement

A reference to the element to be validated.

role

Type:  Neurodot.Forms.Silverlight.Controls.LocalizableValidationRole

A custom validation class. See validation classes in page Neurodot.Forms.Silverlight.Controls namespace for more details.

Remarks

Automatic validation is invoked when the validated control loses focus.

The selected element is automatically validated until the validation role is removed and the element is visible!

 

 

RemoveValidationRole method

Use this method to remove validation for selected control.

Syntax

public static void RemoveValidationRole(FrameworkElement element)


Parameters

element

Type: System.Windows.FrameworkElement

A reference to the control on the form to remove validation role from.

 

SubmitToGGWebService method

This method sends a submission to Government Gateway WCF service using current user’s security token.

Syntax

public static void SubmitToGGWebService(
string transactionClass, 
string xmlMessage, 
SubmitToGGWebServiceCallback callback
)

Parameters

transactionClass

Type: System.String

The name of the gateway transaction for which the submission is intended.

xmlMessage

Type: System.String

An XML message to submit to Gateway. The message is internally wrapped into a GovTalkMessage envelope as its body.

callback

Type: {Neurodot.Forms.Silverlight.Render.Interfaces.SubmitToGGWebServiceCallback}

An XML message that is to be submitted. The message is internally wrapped into a GovTalkMessage envelope as its body.

Remarks

The method submits the message asynchronously! The response XML is returned as a parameter of the callback method.

Example

	string body = @"
	<Message xmlns=""http://mocks.gateway.gov/backend/common"" Version=""1.0"">
		<Header>
			<Vendor>Code-Behind Example</Vendor>
		</Header>
		<Body>
			<GetCitizenAddressesRequest xmlns=""http://gateway.gov/schema/moi/ls/v1"" />
		</Body>
	</Message>";

	ThisForm.IsEnabled = false;
	ThisForm.SubmitToGGWebService("PBL_LS_GetCitizenAddresses", body, OnGetAddressesResponse);

…

public static void OnGetAddressesResponse(XDocument xResponse)
{
	MessageBox.Show(xResponse.ToString());
	ThisForm.IsEnabled = true;
}