我很难通过ObservableCollection<Content>
将Button
传递给EventTrigger
。
现在我在我的xaml中有这样的代码:
<Button Name="SendListButton" Content="Go" HorizontalAlignment="Left" Margin="725,737,0,0" VerticalAlignment="Top" Width="75" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick">
<command:EventToCommand Command="{Binding SendContent}"
CommandParameter="{Binding ElementName=SendListButton}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
在我的MainViewModel.cs
中,我有:
public class MainViewModel : ViewModelBase,IMainViewModel
{
public ICommand SendContent { get; set; }
public ObservableCollection<Content> ContentsToTransfer { get; set; }
public MainViewModel()
{
SendContent = new RelayCommand(OnSendContent);
ContentsToTransfer = new ObservableCollection<Content>();
}
private void OnSendContent(ObservableCollection<Content> ContentsToTransfer)
{
if (ContentsToTransfer.Any())
{
//Code executed by the button.
}
}
你能帮我解释一下如何通过EventTrigger传递我的ObeservableCollection以便将其内容发送到数据库吗?
THX!