Click here to Skip to main content
15,878,871 members
Articles / Programming Languages / C# 4.0

Dynamic Send Activity in WF4

Rate me:
Please Sign up or sign in to vote.
4.43/5 (6 votes)
30 May 2010CPOL14 min read 62.2K   988   29  
This article describes a design, implementation and usage of the custom Dynamic Send Activity in the .Net WF4 Technology.
<sap:ActivityDesigner x:Class="RKiss.Activities.DynamicSend.Design.SendQueueMessageDesigner"    
                      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"       
                      xmlns:s="clr-namespace:System;assembly=mscorlib"        
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"      
                      xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"      
                      xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation"       
                      xmlns:conv="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation"        
                      mc:Ignorable="d"        
                      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"      
                      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" >
    <sap:ActivityDesigner.Resources>
        <conv:ArgumentToExpressionConverter x:Key="expressionConverter"/>
    
    <DataTemplate x:Key="Collapsed">
        <StackPanel>
            <TextBlock>This is the collapsed view</TextBlock>
        </StackPanel>
    </DataTemplate>
    <DataTemplate x:Key="Expanded">
        <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
             <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>           
            <ColumnDefinition Width="*"/>                                                                                                                                                                   
        </Grid.ColumnDefinitions>                                                                                                                   
            <TextBlock Grid.Row="0" Grid.Column="0" Margin="2">Queue Name:</TextBlock>
            <sapv:ExpressionTextBox Expression="{Binding Path=ModelItem.QueueName, Converter={StaticResource expressionConverter}}"                                                                                                                                                                                                                                                                                                                                                                                                                   
                            ExpressionType="s:String"
                            OwnerActivity="{Binding ModelItem}"
                            Grid.Row="0" Grid.Column="1" HorizontalAlignment="Left" Width="177" Margin="2"/>
             <TextBlock Grid.Row="1" Grid.Column="0" Margin="2">DLQ Name:</TextBlock>
             <sapv:ExpressionTextBox Expression="{Binding Path=ModelItem.DeadQueueName, Converter={StaticResource expressionConverter}}"                                     
                            ExpressionType="s:String"
                            OwnerActivity="{Binding ModelItem}"
                            Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left" Width="177" Margin="2"/>
             <TextBlock Grid.Row="2" Grid.Column="0" Margin="2">Machine Mame:</TextBlock>
             <sapv:ExpressionTextBox Expression="{Binding Path=ModelItem.MachineName, Converter={StaticResource expressionConverter}}"                                     
                            ExpressionType="s:String"
                            OwnerActivity="{Binding ModelItem}"
                            Grid.Row="2" Grid.Column="1" HorizontalAlignment="Left" Width="177" Margin="2"/>
             <sap:WorkflowItemPresenter Item="{Binding ModelItem.Body}"
                               HintText="Drop Send Activity"
                               Margin="6"
                               Grid.Row="4"
                               Grid.Column="0"
                               Grid.ColumnSpan="2"/>
    </Grid>
   </DataTemplate>

    <Style x:Key="ExpandOrCollapsedStyle" TargetType="{x:Type ContentPresenter}">
        <Setter Property="ContentTemplate" Value="{DynamicResource Collapsed}"/>
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=ShowExpanded}" Value="true">
                <Setter Property="ContentTemplate" Value="{DynamicResource Expanded}"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>
    </sap:ActivityDesigner.Resources>
    <Grid>
        <ContentPresenter Style="{DynamicResource ExpandOrCollapsedStyle}" Content="{Binding}" />
    </Grid>

</sap:ActivityDesigner>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions