locked
WorkflowItemsPresenter not recognized inside DataTemplate RRS feed

  • Question

  • Hi, I'm using a WorkflowItemsPresenter on my XAML and I implemented a code to Expand/Collapse my workflow like this (I simplified the code a little bit):

    <sap:ActivityDesigner x:Class="DesignerRehosting.MyComponent"
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" 
        xmlns:dxlc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:DesignerRehosting"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
        xmlns:sapv="clr-namespace:System.Activities.Presentation.View;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>
            <DataTemplate x:Key="Collapsed">           
            </DataTemplate>
            <DataTemplate x:Key="Expanded">
            <sap:WorkflowItemsPresenter Name="wfip" Items="{Binding Path=ModelItem.Branches,Mode=TwoWay}"/>           
            </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>
            <ContentPresenter Style="{DynamicResource ExpandOrCollapsedStyle}" Content="{Binding}"/>

    It returns an error like this:

    Error    3    'DesignerRehosting.MyComponent' does not contain a definition for 'wfip' and no extension method 'wfip' accepting a first argument of type 'DesignerRehosting.MyComponent' could be found (are you missing a using directive or an assembly reference?)

    Thus, I cannot work with "wfip" on my code behind file. Removing this Expand/Collapse code, it works without any issues.

     

    Any ideas?

    Thanks.

    Tuesday, August 30, 2011 5:48 PM

Answers

  • Hi,
    I didn't understand the original question, but if you just want to access children activities in code behind, can't you get it through the model tree?

    e.g. this.Model.Item.Properties["Body"].Value; ('this' = your custom designer)

    e.g. this.Model.Item.Properties["Children"].Collection[0].Value;

     

    One part of the original question I didn't understand yet is why you needed to have the name wfip on the presenter.

    Tim


    • Marked as answer by unknowndev Wednesday, August 31, 2011 4:33 PM
    Wednesday, August 31, 2011 4:12 PM

All replies

  • I don't know if I made myself clear.

    The name of the component isn't recognized when inside the DataTemplate tag.

    If there's a way to get a list of children activities of my custom activity designer

    in my code behind file via GetService() method (not talking about getting it on

    the Code Activity), I won't need to manipulate the component directly. Also, it would

    be a better approach I think.

    Wednesday, August 31, 2011 1:45 PM
  • Hi,
    I didn't understand the original question, but if you just want to access children activities in code behind, can't you get it through the model tree?

    e.g. this.Model.Item.Properties["Body"].Value; ('this' = your custom designer)

    e.g. this.Model.Item.Properties["Children"].Collection[0].Value;

     

    One part of the original question I didn't understand yet is why you needed to have the name wfip on the presenter.

    Tim


    • Marked as answer by unknowndev Wednesday, August 31, 2011 4:33 PM
    Wednesday, August 31, 2011 4:12 PM
  • The original question was: How do I access the WorkflowItemsPresenter component (declared in the XAML as "wfip")

    in the code behind file inside of DataTemplate since it returns an error.

     

    But in a way, your solution prevents me from manipulating WorkflowItemsPresenter directly in the code, so it ends up solving the problem.

     

    Thanks.

    Wednesday, August 31, 2011 4:33 PM