在我的自定义活动中从组合框抛出的ArgumentNullException

时间:2017-06-22 09:17:09

标签: wpf workflow-foundation

我有一个简单的WF自定义活动演示。

XAML代码:

<sap:ActivityDesigner x:Class="ActivityDesignerLibrary2.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">
    <Grid>
        <ComboBox x:Name="comboBox" 
                  ItemsSource="{Binding Path=ModelItem.Values}"
                  SelectedValue="{Binding Path=ModelItem.Value, Mode=TwoWay}"
                  HorizontalAlignment="Left" Margin="36,0,0,0" VerticalAlignment="Top" Width="120"/>
    </Grid>
</sap:ActivityDesigner>

代码隐藏:

[Designer(typeof(ActivityDesignerLibrary2.ActivityDesigner1))]
public class Class1 : CodeActivity
{
    public List<string> Values { get; set; }

    public string Value { get; set; }

    public Class1()
    {
        Values = new List<string>() { "V1", "V2", "V3"};
        Value = "V2";
    }

    protected override void Execute(CodeActivityContext context)
    {

    }
}

当我将此自定义活动拖到工作流程中时,会弹出错误消息框。 我发现它的SelectedValue会出错,但是有什么错误以及如何修复它? enter image description here

0 个答案:

没有答案