在设计器中使用ExpressionTextBox控件进行我所拥有的活动时,我遇到了一些小问题。如何将XAML中的ExpressionType属性设置为类型对象,该对象定义IEnumerable`1`1泛型?我完全可以不设置它,但理想情况下,我希望在设计时获得对控件的验证支持。
我试过以下几种方法,但不起作用:
<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>发布于 2013-03-13 21:23:51
使用ModelItem获取属性类型并绑定到它,如下所示:
ExpressionType={Binding ModelItem.Properties[SelectedDestinations].PropertyType.GenericTypeArguments[0]}https://stackoverflow.com/questions/15393616
复制相似问题