0

我在设计器中使用ExpressionTextBox控件进行我拥有的活动时遇到了一个小问题。如何将XAML 中的ExpressionType属性设置为定义IEnumerable`1泛型的Type对象?我可以完全不设置它,但理想情况下,我希望在设计时获得对控件的验证支持。

我尝试了以下方法,但不起作用:

<View:ExpressionTextBox 
   VerticalContentAlignment="Center" 
   Expression="{Binding Path=ModelItem.SelectedDestinations, Converter={StaticResource ResourceKey=ArgumentToExpressionConverter}, ConverterParameter=Out}" 
   ExpressionType="{x:Type TypeName=Generic:IEnumerable[Communication:CommunicationDeliveryDestination]}" 
   OwnerActivity="{Binding Path=ModelItem}" />

关于如何在 XAML中正确设置ExpressionType属性的任何想法?下面是我活动的设计器的完整 XAML。

<sap:ActivityDesigner x:Class="UrbanScience.ELS.Orchestration.Activities.Design.SelectDestinationsByLeadDestinationTypeDesigner"
    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:View="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation"
    xmlns:sapc="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation"
    xmlns:Generic="clr-namespace:System.Collections.Generic;assembly=mscorlib"
                      xmlns:System="clr-namespace:System;assembly=mscorlib">

    <sap:ActivityDesigner.Resources>
        <ResourceDictionary>
            <sapc:ArgumentToExpressionConverter x:Key="ArgumentToExpressionConverter" />
        </ResourceDictionary>
    </sap:ActivityDesigner.Resources>

    <Grid Height="50">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="200" />
            <ColumnDefinition MinWidth="200" />
        </Grid.ColumnDefinitions>

        <TextBlock Text="Lead Destination Type:" VerticalAlignment="Center" Grid.Row="0" Grid.Column="0" />
        <ComboBox Name="LeadDestinationTypeItems" VerticalAlignment="Center" SelectedIndex="0" Grid.Row="0" Grid.Column="1" SelectionChanged="OnLeadDestinationTypeChanged" />

        <TextBlock Text="Assign selected destinations to:" VerticalAlignment="Center" Grid.Row="1" Grid.Column="0" />
        <View:ExpressionTextBox VerticalContentAlignment="Center" 
                                Expression="{Binding Path=ModelItem.SelectedDestinations, Converter={StaticResource ResourceKey=ArgumentToExpressionConverter}, ConverterParameter=Out}"
                                ExpressionType="{x:Type TypeName=Generic:IEnumerable[Communication:CommunicationDeliveryDestination]}"
                                OwnerActivity="{Binding Path=ModelItem}" Grid.Row="1" Grid.Column="1">
        </View:ExpressionTextBox>
    </Grid>
</sap:ActivityDesigner>
4

1 回答 1

0

用于ModelItem获取属性类型并绑定到它,如下所示:

ExpressionType={Binding ModelItem.Properties[SelectedDestinations].PropertyType.GenericTypeArguments[0]}
于 2013-03-13T21:23:51.440 回答