Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As I thought, annotations are saved within the workflow definition as an attached property. Here's what an annotation looks like in the workflow's xaml:</p> <pre><code>&lt;Sequence xmlns:derp="http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation" derp:Annotation.AnnotationText="This is an annotation!"&gt; </code></pre> <p>See, just like any other attached property. Except it isn't. Its an attached <em>workflow</em> property, not an attached <em>DependencyProperty</em>. That means it works through the attached property service as well as the <a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.annotations.annotation.aspx" rel="nofollow">Annotation class</a>. Getting and setting the annotation text on a ModelItem is trivial (and covered below).</p> <p>Its actually not that hard to support annotations. As long as you don't mind your UI looking like crap. Here's a quick and dirty implementation.</p> <p>In the UI, add some controls for holding and editing the annotation text</p> <pre><code>&lt;sap:WorkflowViewElement x:Class="AnnotationSupport.MyActivityDesigner" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation" xmlns:ann="clr-namespace:System.Activities.Presentation.Annotations;assembly=System.Activities.Presentation" xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation" x:Name="root" MinWidth="100" MinHeight="100"&gt; &lt;Grid Background="red"&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="auto" /&gt; &lt;RowDefinition /&gt; &lt;/Grid.RowDefinitions&gt; &lt;Expander IsExpanded="False"&gt; &lt;!-- HERE SHE BLOWS --&gt; &lt;TextBox Text="{Binding ModelItem.AnnotationText}" /&gt; &lt;/Expander&gt; &lt;TextBox Grid.Row="1" Text="{Binding ModelItem.Text}" Margin="10" /&gt; &lt;/Grid&gt; &lt;/sap:WorkflowViewElement&gt; </code></pre> <p>Any time the Annotation text changes, the ModelItem's PropertyChanged event fires, just like any other property. And if you want to grab it from code, the simplest way is to cast the ModelItem to a <code>dynamic</code>:</p> <pre><code>private void SetAnnotationLol(string newValue) { if(ModelItem != null) ((dynamic)ModelItem).AnnotationText = newValue; } </code></pre> <p>Now, if you want to create a nice UI like the Fx Activities have... well...</p> <p>I'll leave it up to you to create a custom <a href="http://msdn.microsoft.com/en-us/library/ms743737.aspx" rel="nofollow">Adorner</a> to handle display and editing of the annotation. Which actually isn't as hard as it first looks. If you haven't done one yet, here's your opportunity.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload