Windows phone 7 在Silverlight中发出绑定命令参数
我好像没法让它正常工作。基本上,我有一个绑定到列表的ObservableCollection。在这个集合中,我需要使用一个对象,在执行命令时将其作为变量传递给命令。我的计划是将其作为CommandParameter传递,但我无法使其工作。该对象实际上是一个枚举值,但我无法让它处理静态文本以外的任何内容。下面是代码,它使用了MVVM概念,使用了交互性(wi)和blend的dll(sl)。该属性在ListItem上是公共的,并且实现了INotifyPropertyChanged 谢谢Windows phone 7 在Silverlight中发出绑定命令参数,windows-phone-7,.net-4.0,silverlight-3.0,Windows Phone 7,.net 4.0,Silverlight 3.0,我好像没法让它正常工作。基本上,我有一个绑定到列表的ObservableCollection。在这个集合中,我需要使用一个对象,在执行命令时将其作为变量传递给命令。我的计划是将其作为CommandParameter传递,但我无法使其工作。该对象实际上是一个枚举值,但我无法让它处理静态文本以外的任何内容。下面是代码,它使用了MVVM概念,使用了交互性(wi)和blend的dll(sl)。该属性在ListItem上是公共的,并且实现了INotifyPropertyChanged 谢谢 <Lis
<ListBox ItemsSource="{Binding Path=MyList}" ScrollViewer.VerticalScrollBarVisibility="Disabled">
<wi:Interaction.Triggers>
<wi:EventTrigger EventName="SelectionChanged">
<sl:InvokeDataCommand CommandParameter="{Binding MyList.ListItem.Property}" Command="{Binding Source={StaticResource Locator}, Path=MyTestPage.TestExecute}" />
</wi:EventTrigger>
</wi:Interaction.Triggers>
...
...
这样做怎么样?是否要绑定到selectedItem,而不是
我的列表是你的可观察到的集合
<ListBox x:Name="listBox" ItemsSource="{Binding Path=MyList}" ScrollViewer.VerticalScrollBarVisibility="Disabled">
<wi:Interaction.Triggers>
<wi:EventTrigger EventName="SelectionChanged">
<sl:InvokeDataCommand CommandParameter="{Binding ElementName=listBox, Path=SelectedItem.Property}" Command="{Binding Source={StaticResource Locator}, Path=MyTestPage.TestExecute}" />
</wi:EventTrigger>
</wi:Interaction.Triggers>