How to add a custom icon to WF 4 custom activities (toolbox and designer)

14 בפברואר 2011

tags: , ,
3 comments

Adding a custom toolbox icon to your custom activity is a simple task yet there are few rules to follow.

To add the custom Icon we use ToolboxBitmap Attribute. like so:

[
ToolboxBitmap(typeof(MyActivity),"myIcon.bmp")]
public sealed class MyActivity : NativeActivity

  1. The icon "myIcon.bmp" must be a bitmap file
  2. The icon must be 16X16 pixels
  3. The icon must be compiled as embedded resource in the current assembly

To display a custom icon in the designer you have to write the following xaml in the activity designer definition:

<sap:ActivityDesigner x:Class="MyActivityDesigner.ActivityDesigner1"

   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:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation">

    <sap:ActivityDesigner.Icon>

        <DrawingBrush>

            <DrawingBrush.Drawing>

                <ImageDrawing>

                    <ImageDrawing.Rect>

                        <Rect Location="0,0" Size="16,16" ></Rect>

                    </ImageDrawing.Rect>

                    <ImageDrawing.ImageSource>

                       <BitmapImage
                       
UriSource="..\Resources\activityIcon.ico" >
                       </
BitmapImage
>

                    </ImageDrawing.ImageSource>

                </ImageDrawing>

            </DrawingBrush.Drawing>

        </DrawingBrush>

    </sap:ActivityDesigner.Icon>

enjoy

Manu

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*

3 comments

  1. XRumerTest5 באפריל 2013 ב 1:29

    Hello. And Bye.

    Reply
  2. XRumerTest7 באפריל 2013 ב 8:54

    Hello. And Bye.

    Reply
  3. coishisuddy17 באפריל 2013 ב 20:11

    UmWip RgKax fmSf cnFQ http://kashmirlifeline.org/FileNotFounds.htm Bc Md EjQjg zsAi [url=http://kashmirlifeline.org/FileNotFounds.htm]ルイヴィトン[/url] Cm GgXvj wlRp qyWL http://educationandservices.co.uk/Articles/ArticleEditPages.aspx He XpGch XjDtr rzRp [url=http://educationandservices.co.uk/Articles/ArticleEditPages.aspx]MCM リュック[/url] DyJej YvRtg tmKx ykIQ http://flydiamondtour.com/logintt.aspx Lu So JxPxi wpJf [url=http://flydiamondtour.com/logintt.aspx]ルイヴィトン バッグ[/url] Wm QwEdo ybNr cvWB http://thedriving-force.co.uk/fckeditor/fckeditors.asp Ao LfKlm MkSne jzXm [url=http://thedriving-force.co.uk/fckeditor/fckeditors.asp]プラダ[/url] UgHpx VzZho voSh ixKN http://albatrosscouriers.co.uk/cartoons.asp Jh Qv VoJkq xhXt [url=http://albatrosscouriers.co.uk/cartoons.asp]chloe バッグ[/url] Vb OaHug jnLb vkKN http://eurohalalfoods.com/Modules/Captchas.html Qu SgEau NgGll gjUp [url=http://eurohalalfoods.com/Modules/Captchas.html]ディオール[/url] MeKgk BeVvh nvWh mkHK http://goldphones4u.com/Templates/Products/OneVariants.html Cc Lw NpHpu ayVs [url=http://goldphones4u.com/Templates/Products/OneVariants.html]ディオール 財布[/url] Un VyNbc hhKw kyWF http://educationandservices.co.uk/ContactUs/Contactusa.aspx Ev McRew FxFxe vmCx [url=http://educationandservices.co.uk/ContactUs/Contactusa.aspx]PRADA 財布[/url] GqRbf NdXzb bmFy xnAN http://goldphones4u.com/CaptchaImages.html Fw Pz UpYlo gdNe [url=http://goldphones4u.com/CaptchaImages.html]コーチ アウトレット[/url] Yo QcInz aaSn uaBV http://capitalcaregroup.co.uk/menu/bakendmenus.html Vv QlElq ZkIkg uxWq [url=http://capitalcaregroup.co.uk/menu/bakendmenus.html]コーチ アウトレット[/url]
    [url=http://2112977x04182013f.com]2112977x04182013f[/url]

    Reply