Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a windows workflow designer wherein the customer can design his own workflows. I have created a custom workflow activity names FinalizeParticipantWorkflow which looks like this:

http://postimg.org/image/6xvi8zse3/[^]

Clicking on the checkbox disables both the dropdowns.

My problem is when I am selecting a value from the First dropdown and then collapsing the container and then again expand it, all the controls vanish from the container. Like this:

http://postimg.org/image/ri0c1ktl3/[^]

Here is the xaml code for the activity:

<pre lang="HTML"><sap:ActivityDesigner x:Class="MMS.Activities.Public.Design.FinalizeParticipantWorkflowDesigner"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="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"
    xmlns:sapc="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation"
    xmlns:Model="clr-namespace:System.Activities.Presentation.Model;assembly=System.Activities.Presentation"
                      xmlns:ActivitiesLibrary="clr-namespace:MMS.Activities.Common;assembly=MMS.Activities"
                      xmlns:et="clr-namespace:MMS.EventEngine.Entities;assembly=MMS.EventEngine.Entities"
                      xmlns:grp="clr-namespace:MMS.Activities.Public.Design"
                      xmlns:local="clr-namespace:MMS.Activities.Public.Design.Converters" Loaded="ActivityDesigner_Loaded">
    <sap:ActivityDesigner.Resources>

        <ResourceDictionary x:Uid="ResourceDictionary_1">
            <sapc:ArgumentToExpressionConverter x:Key="ArgumentToExpressionConverter" />
            <sapc:ModelToObjectValueConverter x:Key="ModelToObjectValueConverter" />
            <local:StringConverter x:Key="StringConverter" />
            <local:InverseBooleanConverter x:Key="InverseBooleanConverter" />
            <local:BooleanConverter x:Key="BooleanConverter"/>

            <ObjectDataProvider x:Key="AssociatedGroupsDs" MethodName="GetAssociatedGroups" ObjectType="{x:Type grp:FinalizeParticipantWorkflowDesigner}"></ObjectDataProvider>
            <!--<ObjectDataProvider x:Key="AssociatedGroupsDs1" MethodName="GetAssociatedGroups" ObjectType="{x:Type grp:FinalizeParticipantWorkflowDesigner}"></ObjectDataProvider>-->
            <ObjectDataProvider x:Key="SuccessorWorkflowIds" MethodName="GetSuccessorWorkflowIds" ObjectType="{x:Type grp:FinalizeParticipantWorkflowDesigner}"></ObjectDataProvider>

            <DataTemplate x:Key="Collapsed">
                <StackPanel Orientation="Vertical">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock VerticalAlignment="Center" Width="125" Margin="5" Text=""/>
                        <CheckBox x:Name="chkGetNextGroupByScore" IsChecked="{Binding Path=ModelItem.GetNextGroupByScore, Mode=TwoWay, Converter={StaticResource BooleanConverter}}" Content="Use Next Group Based On Score" Height="16" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="1" Margin="5"  VerticalAlignment="Top" />
                    </StackPanel>
                </StackPanel>
            </DataTemplate>

            <DataTemplate x:Key="Expanded">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>

                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <CheckBox x:Name="chkGetNextGroupByScore" IsChecked="{Binding Path=ModelItem.GetNextGroupByScore, Mode=TwoWay, Converter={StaticResource BooleanConverter}}" Content="Use Next Group Based On Score" Height="16" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="1" Margin="5"  VerticalAlignment="Top" />
                    <TextBlock Width="125" VerticalAlignment="Center" Margin="5" Text="Successor Group Id"  Grid.Row="1" Grid.Column="0"/>
                    <ComboBox x:Name="cbSuccessorGroupId" IsEnabled="{Binding ElementName=chkGetNextGroupByScore, Path=IsChecked, Converter={StaticResource ResourceKey=InverseBooleanConverter}}" ItemsSource="{Binding Source={StaticResource AssociatedGroupsDs}}" SelectedValue="{Binding Path=ModelItem.SuccessorGroupId, Mode=TwoWay, Converter={StaticResource StringConverter}}" VerticalAlignment="Center" Width="300" Grid.Row="1" Grid.Column="1" Margin="0,5" SelectionChanged="ComboBox_SelectionChanged"></ComboBox>
                    <TextBlock Width="125" VerticalAlignment="Center" Margin="5" Text="Successor Workflow Id"  Grid.Row="2" Grid.Column="0"/>
                    <ComboBox x:Name="cbSuccessorWFs" IsEnabled="{Binding ElementName=chkGetNextGroupByScore, Path=IsChecked, Converter={StaticResource ResourceKey=InverseBooleanConverter}}" ItemsSource="{Binding Source={StaticResource SuccessorWorkflowIds}}" SelectedValue="{Binding Path=ModelItem.SuccessorWorkflowId, Mode=TwoWay, Converter={StaticResource StringConverter}}" VerticalAlignment="Center" Width="300" Grid.Row="2" Grid.Column="1" Margin="0,5"></ComboBox>
                </Grid>
            </DataTemplate>

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


        </ResourceDictionary>
    </sap:ActivityDesigner.Resources>
    <Grid>
        <ContentPresenter Style="{DynamicResource ExpandOrCollapsedStyle}" Content="{Binding}" />
    </Grid>
</sap:ActivityDesigner>


And here is the code for the dropdown change event:

private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            List<string> swf = new List<string>();
            swf = m.GetSuccessWorkFlowsByGroupList(this, ((ComboBox)sender).SelectedValue.ToString());
            foreach (var cb in FindVisualChildren<ComboBox>(this))
            {
                if (cb.Name == "cbSuccessorWFs")
                {
                    cb.ItemsSource = swf;
                }
            }
        }


If I do not select the value from dropdown, the expand/collapse works fine. It only breaks if I select the dropdown value.

I have searched all over the internet but could not find a solution. Can anyone suggest a remedy.
Posted

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900