如何设置ButtonBaseExtensions.Command DataContext,而不是更改按钮的上下文
我在WP7应用程序中使用mvvm light。我有一个列表框,其中包含一组对象的项目源。
列表框的ItemTemplate DataTemplate包含一个按钮。该按钮包含一个显示绑定对象属性的文本块。如何将Command命令分配给按钮而不更改textblock或获取绑定到itemtemplate的项目的CommandParameter的datacontext?
<ListBox x:Name="listBox" ItemsSource="{Binding Main.SomeCollection}" >
<ListBox.ItemTemplate>
<DataTemplate>
<Button
Command:ButtonBaseExtensions.Command="{Binding Main.MyCommand}"
Cmmand:ButtonBaseExtensions.CommandParameter="{Binding}" />
<TextBlock Text="{Binding Title}"/>
</Button>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
谢谢
没有找到相关结果
已邀请:
1 个回复
碧肮械淌设