Trying to reconstruct the PrioritizedInterleave Example from the Essential WWF Book with Visual Basic I've got problems to create an attached property.

This is the xoml-Code im trying to get to work:

Code Snippet

<ns0:PrioritizedInterleave x:Name="pi1">
<ns0:Writeline x:Name="a" ns0:PrioritizedInterleave.Priority="1"/>
<ns0:Writeline x:Name="e"/>

The PrioritizedInterleave Class starts as follows:

Code Snippet

Public Class PrioritizedInterleave
Inherits CompositeActivity

'#Region "Child Attached Property 'Priority'"
Public Shared ReadOnly PriorityProperty As DependencyProperty = _
DependencyProperty.RegisterAttached("Priority", GetType(String), GetType(PrioritizedInterleave), New PropertyMetadata(DependencyPropertyOptions.Metadata))

Public Shared Function GetPriority(ByVal child As DependencyObject) As String
Return child.GetValue(PriorityProperty)
End Function

Public Shared Sub SetPriority(ByVal child As DependencyObject, ByVal value As String)
child.SetValue(PriorityProperty, value)
End Sub
'#End Region


When running the xoml-defined workflow a WorkflowValidationFailedException is thrown. Also, the VS Workflow Designer is not able to display the xoml-File: the error message is "Attached DependencyProperty 'Priority:Testdrive.Activities.PrioritizedInterleave' should have static accessors 'SetPriority' and 'GetPriority'".

But how to accomplish that in VB Methods in VB can not be declared static, right

Thanks for any hints.
With best regards,

vivian steller

Re: Windows Workflow Foundation Attached Property with VB

Andrei Romanenko - MSFT

This happens because the signature of GetPriority and SetPriority is not matching the expected one. They should have parameters and return value of type Object. The following should fix the issue:

Public Shared Function GetPriority(ByVal child As Object) As Object

Return CType(child, DependencyObject).GetValue(PriorityProperty)

End Function

Public Shared Sub SetPriority(ByVal child As Object, ByVal value As Object)

CType(child, DependencyObject).SetValue(PriorityProperty, value)

End Sub

Hope this helps.