【发布时间】:2015-12-19 02:49:30
【问题描述】:
我正在学习 MVVM,所以它可能是新手问题。
我需要绑定函数:
private void doubleClick(object sender, MouseButtonEventArgs e)
在文本块中:
<Grid>
<ListBox Name="mediaList" Grid.Row="1"
ItemsSource="{Binding Medias}"
IsSynchronizedWithCurrentItem="True">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type Models:Media}">
<StackPanel Orientation="Horizontal">
<Image Source="icon-play-128.png" Margin="0,0,5,0" />
<TextBlock Text="{Binding Name}" Margin="0,0,5,0">
<TextBlock.InputBindings>
<MouseBinding Command="{Binding DoubleClick}" Gesture="LeftDoubleClick" />
</TextBlock.InputBindings>
</TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
但第一个问题是 DoubleClick 在我的视图模型中,而不是在我的类媒体中(在模型中)。
另一个问题是我需要接收两个参数,我该怎么做?
如果您有更好的方法,请向我解释。
提前致谢。
【问题讨论】: