【发布时间】:2011-08-12 02:01:57
【问题描述】:
知道如何绑定到列表框而不是在下面的代码中使用 x:Name 吗?我在 ElementName=myList
使用 xname<ListBox x:Name="myList" Grid.Row="1" Height="auto" ItemsSource="{Binding Path=ListItems}" ItemContainerStyle="{StaticResource StretchedItemContainerStyle}" ScrollViewer.VerticalScrollBarVisibility="Disabled" Background="Transparent">
<wi:Interaction.Triggers>
<wi:EventTrigger EventName="SelectionChanged">
<wi:InvokeCommandAction Command="{Binding Source={StaticResource Locator}, Path=ViewModel.Command}" CommandParameter="{Binding SelectedItem, ElementName=myList}" />
</wi:EventTrigger>
</wi:Interaction.Triggers>
<ListBox.ItemTemplate>
我真的不想在每次使用 InvokeCommandAction 时都为我的控件定义一个名称。注意:wi 是 SL4/WP7.1 的 Windows 交互性
谢谢!
【问题讨论】:
标签: silverlight xaml data-binding windows-phone-7 command