Hello Michael,
welcome in the UiPath Community.
Great question.
Your code looks good. To compile this code correctly to use it with the compatibility mode Windows in UiPath you must add a reference to System.Activities.dll in the UiPath Studio directory. You can find more information about that here.
Best regards
Stefan