다음을 통해 공유


사용자 지정 복합 디자이너 - 워크플로 항목 발표자

WorkflowItemPresenter WF 디자이너 프로그래밍 모델의 키 형식으로, 임의의 활동을 배치할 수 있는 "드롭 영역"을 만들 수 있습니다. 이 샘플에서는 이러한 "드롭 영역"을 표시하는 활동 디자이너를 빌드하는 방법을 보여 줍니다.

WorkflowItemPresenter 샘플은 다음을 보여 줍니다.

  • 사용자 지정 활동 디자이너 WorkflowItemPresenter를 사용하여 만들기

  • 메타데이터 저장소를 사용하여 사용자 지정 디자이너 등록

  • 다시 호스팅된 도구 상자를 선언적이고 명령적으로 프로그래밍합니다.

샘플 세부 정보

이 샘플의 코드는 다음을 보여줍니다.

  • 사용자 지정 활동 디자이너는 클래스용으로 빌드됩니다 SimpleNativeActivity .

  • 사용자 지정 활동 디자이너의 생성에는 WorkflowItemPresenter을(를) 사용합니다.

<sap:ActivityDesigner x:Class="Microsoft.Samples.UsingWorkflowItemPresenter.SimpleNativeDesigner"
    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.Resources>
        <DataTemplate x:Key="Collapsed">
            <StackPanel>
                <TextBlock>This is the collapsed view</TextBlock>
            </StackPanel>
        </DataTemplate>
        <DataTemplate x:Key="Expanded">
            <StackPanel>
                <TextBlock>Custom Text</TextBlock>
                <sap:WorkflowItemPresenter Item="{Binding Path=ModelItem.Body, Mode=TwoWay}"
                                        HintText="Please drop an activity here" />
            </StackPanel>
        </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>

WPF 데이터 바인딩을 사용하여 ModelItem.Body에 바인딩하는 것을 유의하세요. ModelItem는 디자이너가 사용 중인 기본 개체(이 경우 ActivityDesigner)를 참조하는 속성 입니다.

샘플 설정, 빌드 및 실행

  1. Visual Studio에서 솔루션을 엽니다.

  2. F5 키를 눌러 애플리케이션을 컴파일하고 실행합니다.

참고하십시오