Issue binding command parameter in Silverlight
I can't seem to get this to work right. Basically, I have an ObservableCollection that is bound to a list. Inside this collection, I have an object that I need to use to pass as a variable to a Command when it's executed. My plan was to pass this as CommandParameter, but I can't get it to work. The object is actually an Enum value, but I can't get it to work with anything but static text. Below is the code, it's using a MVVM concept using Interactivity(wi)and blend开发者_高级运维's dll(sl). The property is public on the ListItem, and does implement INotifyPropertyChanged.
Thanks.
<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>
...
<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>
How about doing this? You want to bind to the selectedItem, not ?
MyList is your ObservableCollection ?
精彩评论